MySQL 9.1.0
Source Code Documentation
iterator.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2022, 2024, 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// from C++20
32
33namespace stdx {
34namespace impl {
35template <class T, bool = std::is_array_v<T>>
37
38template <class T>
40 using value_type = std::remove_cv_t<std::remove_extent_t<T>>;
41};
42
43template <class T, bool = std::is_object_v<T>>
45
46template <class T>
48 using value_type = std::remove_cv_t<T>;
49};
50
51template <class T, typename = std::void_t<>>
52struct has_value_type : std::false_type {};
53
54template <class T>
56 std::void_t<typename std::remove_cvref_t<T>::value_type>>
57 : std::true_type {};
58
59template <class T, bool = has_value_type<T>::value>
61
62template <class T>
64 using value_type = typename T::value_type;
65};
66
67template <class T, typename = std::void_t<>>
68struct has_element_type : std::false_type {};
69
70template <class T>
71struct has_element_type<T, std::void_t<typename T::element_type>>
72 : std::true_type {};
73
74template <class T, bool = has_element_type<T>::value>
76
77template <class T>
79 using value_type = typename T::element_type;
80};
81
82template <class T, typename = std::void_t<>>
83struct has_reference : std::false_type {};
84
85template <class T>
86struct has_reference<T, std::void_t<typename T::reference>> : std::true_type {};
87
88template <class T, bool = has_reference<T>::value>
90
91template <class T>
92struct iter_reference<T, false> {
93 using reference = decltype(*std::declval<T &>());
94};
95
96template <class T>
97struct iter_reference<T, true> {
98 using reference = typename T::reference;
99};
100
101} // namespace impl
102
103template <class T, class Enable = void>
105
106template <class T>
107struct indirectly_readable_traits<T *, std::enable_if_t<std::is_object_v<T>>>
109
110template <class T>
111struct indirectly_readable_traits<T, std::enable_if_t<std::is_array_v<T>>>
113
114template <class T>
116 T, std::enable_if_t<impl::has_value_type<T>::value>>
118 std::remove_cvref_t<T>> {};
119
120template <class T>
122 T, std::enable_if_t<impl::has_element_type<T>::value>>
124
125template <class T>
127
128template <class T>
131
132template <class T>
135
136} // namespace stdx
137
138#endif
uint16_t value_type
Definition: vt100.h:184
Definition: http_server_component.cc:34
Definition: gcs_xcom_synode.h:64
Definition: bit.h:32
typename indirectly_readable_traits< std::remove_cvref_t< T > >::value_type iter_value_t
Definition: iterator.h:130
typename impl::iter_reference< std::remove_cvref_t< T > >::reference iter_reference_t
Definition: iterator.h:134
Definition: iterator.h:68
Definition: iterator.h:83
Definition: iterator.h:52
std::remove_cv_t< std::remove_extent_t< T > > value_type
Definition: iterator.h:40
typename T::element_type value_type
Definition: iterator.h:79
typename T::value_type value_type
Definition: iterator.h:64
std::remove_cv_t< T > value_type
Definition: iterator.h:48
decltype(*std::declval< T & >()) reference
Definition: iterator.h:93
typename T::reference reference
Definition: iterator.h:98
Definition: iterator.h:89
Definition: iterator.h:104