MySQL 8.0.42
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
iterator.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2022, 2025, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef MYSQL_HARNESS_STDX_ITERATOR_H_
27#define MYSQL_HARNESS_STDX_ITERATOR_H_
28
29#include <type_traits>
30
31#include "mysql/harness/stdx/type_traits.h" // remove_cvref_t
32
33// from C++20
34
35namespace stdx {
36namespace impl {
37template <class T, bool = std::is_array_v<T>>
39
40template <class T>
42 using value_type = std::remove_cv_t<std::remove_extent_t<T>>;
43};
44
45template <class T, bool = std::is_object_v<T>>
47
48template <class T>
50 using value_type = std::remove_cv_t<T>;
51};
52
53template <class T, typename = std::void_t<>>
54struct has_value_type : std::false_type {};
55
56template <class T>
58 std::void_t<typename stdx::remove_cvref_t<T>::value_type>>
59 : std::true_type {};
60
61template <class T, bool = has_value_type<T>::value>
63
64template <class T>
66 using value_type = typename T::value_type;
67};
68
69template <class T, typename = std::void_t<>>
70struct has_element_type : std::false_type {};
71
72template <class T>
73struct has_element_type<T, std::void_t<typename T::element_type>>
74 : std::true_type {};
75
76template <class T, bool = has_element_type<T>::value>
78
79template <class T>
81 using value_type = typename T::element_type;
82};
83
84template <class T, typename = std::void_t<>>
85struct has_reference : std::false_type {};
86
87template <class T>
88struct has_reference<T, std::void_t<typename T::reference>> : std::true_type {};
89
90template <class T, bool = has_reference<T>::value>
92
93template <class T>
94struct iter_reference<T, false> {
95 using reference = decltype(*std::declval<T &>());
96};
97
98template <class T>
99struct iter_reference<T, true> {
100 using reference = typename T::reference;
101};
102
103} // namespace impl
104
105template <class T, class Enable = void>
107
108template <class T>
109struct indirectly_readable_traits<T *, std::enable_if_t<std::is_object_v<T>>>
111
112template <class T>
113struct indirectly_readable_traits<T, std::enable_if_t<std::is_array_v<T>>>
115
116template <class T>
118 T, std::enable_if_t<impl::has_value_type<T>::value>>
120 stdx::remove_cvref_t<T>> {};
121
122template <class T>
124 T, std::enable_if_t<impl::has_element_type<T>::value>>
126
127template <class T>
129
130template <class T>
133
134template <class T>
137
138} // namespace stdx
139
140#endif
uint16_t value_type
Definition: vt100.h:184
Definition: authentication.cc:36
Definition: gcs_xcom_synode.h:64
Definition: bit.h:34
typename indirectly_readable_traits< stdx::remove_cvref_t< T > >::value_type iter_value_t
Definition: iterator.h:132
typename impl::iter_reference< stdx::remove_cvref_t< T > >::reference iter_reference_t
Definition: iterator.h:136
Definition: iterator.h:70
Definition: iterator.h:85
Definition: iterator.h:54
std::remove_cv_t< std::remove_extent_t< T > > value_type
Definition: iterator.h:42
typename T::element_type value_type
Definition: iterator.h:81
typename T::value_type value_type
Definition: iterator.h:66
std::remove_cv_t< T > value_type
Definition: iterator.h:50
decltype(*std::declval< T & >()) reference
Definition: iterator.h:95
typename T::reference reference
Definition: iterator.h:100
Definition: iterator.h:91
Definition: iterator.h:106