MySQL 8.3.0
Source Code Documentation
iterator.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2022, 2023, 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 also distributed 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 included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24
25#ifndef MYSQL_HARNESS_STDX_ITERATOR_H_
26#define MYSQL_HARNESS_STDX_ITERATOR_H_
27
28#include <type_traits>
29
30#include "mysql/harness/stdx/type_traits.h" // remove_cvref_t
31
32// from C++20
33
34namespace stdx {
35namespace impl {
36template <class T, bool = std::is_array_v<T>>
38
39template <class T>
41 using value_type = std::remove_cv_t<std::remove_extent_t<T>>;
42};
43
44template <class T, bool = std::is_object_v<T>>
46
47template <class T>
49 using value_type = std::remove_cv_t<T>;
50};
51
52template <class T, typename = std::void_t<>>
53struct has_value_type : std::false_type {};
54
55template <class T>
57 std::void_t<typename stdx::remove_cvref_t<T>::value_type>>
58 : std::true_type {};
59
60template <class T, bool = has_value_type<T>::value>
62
63template <class T>
65 using value_type = typename T::value_type;
66};
67
68template <class T, typename = std::void_t<>>
69struct has_element_type : std::false_type {};
70
71template <class T>
72struct has_element_type<T, std::void_t<typename T::element_type>>
73 : std::true_type {};
74
75template <class T, bool = has_element_type<T>::value>
77
78template <class T>
80 using value_type = typename T::element_type;
81};
82
83template <class T, typename = std::void_t<>>
84struct has_reference : std::false_type {};
85
86template <class T>
87struct has_reference<T, std::void_t<typename T::reference>> : std::true_type {};
88
89template <class T, bool = has_reference<T>::value>
91
92template <class T>
93struct iter_reference<T, false> {
94 using reference = decltype(*std::declval<T &>());
95};
96
97template <class T>
98struct iter_reference<T, true> {
99 using reference = typename T::reference;
100};
101
102} // namespace impl
103
104template <class T, class Enable = void>
106
107template <class T>
108struct indirectly_readable_traits<T *, std::enable_if_t<std::is_object_v<T>>>
110
111template <class T>
112struct indirectly_readable_traits<T, std::enable_if_t<std::is_array_v<T>>>
114
115template <class T>
117 T, std::enable_if_t<impl::has_value_type<T>::value>>
119 stdx::remove_cvref_t<T>> {};
120
121template <class T>
123 T, std::enable_if_t<impl::has_element_type<T>::value>>
125
126template <class T>
128
129template <class T>
132
133template <class T>
136
137} // namespace stdx
138
139#endif
uint16_t value_type
Definition: vt100.h:183
Definition: authentication.cc:35
Definition: varlen_sort.h:174
Definition: bit.h:33
typename indirectly_readable_traits< stdx::remove_cvref_t< T > >::value_type iter_value_t
Definition: iterator.h:131
typename impl::iter_reference< stdx::remove_cvref_t< T > >::reference iter_reference_t
Definition: iterator.h:135
Definition: iterator.h:69
Definition: iterator.h:84
Definition: iterator.h:53
std::remove_cv_t< std::remove_extent_t< T > > value_type
Definition: iterator.h:41
typename T::element_type value_type
Definition: iterator.h:80
typename T::value_type value_type
Definition: iterator.h:65
std::remove_cv_t< T > value_type
Definition: iterator.h:49
decltype(*std::declval< T & >()) reference
Definition: iterator.h:94
typename T::reference reference
Definition: iterator.h:99
Definition: iterator.h:90
Definition: iterator.h:105