line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/// \file |
2
|
|
|
|
|
|
|
// Range v3 library |
3
|
|
|
|
|
|
|
// |
4
|
|
|
|
|
|
|
// Copyright Eric Niebler 2013-present |
5
|
|
|
|
|
|
|
// |
6
|
|
|
|
|
|
|
// Use, modification and distribution is subject to the |
7
|
|
|
|
|
|
|
// Boost Software License, Version 1.0. (See accompanying |
8
|
|
|
|
|
|
|
// file LICENSE_1_0.txt or copy at |
9
|
|
|
|
|
|
|
// http://www.boost.org/LICENSE_1_0.txt) |
10
|
|
|
|
|
|
|
// |
11
|
|
|
|
|
|
|
// Project home: https://github.com/ericniebler/range-v3 |
12
|
|
|
|
|
|
|
// |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#ifndef RANGES_V3_UTILITY_SEMIREGULAR_HPP |
15
|
|
|
|
|
|
|
#define RANGES_V3_UTILITY_SEMIREGULAR_HPP |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#include |
18
|
|
|
|
|
|
|
#include |
19
|
|
|
|
|
|
|
#include |
20
|
|
|
|
|
|
|
#include |
21
|
|
|
|
|
|
|
#include |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
namespace ranges |
24
|
|
|
|
|
|
|
{ |
25
|
|
|
|
|
|
|
inline namespace v3 |
26
|
|
|
|
|
|
|
{ |
27
|
|
|
|
|
|
|
/// \addtogroup group-utility |
28
|
|
|
|
|
|
|
/// @{ |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
/// \cond |
31
|
|
|
|
|
|
|
namespace detail |
32
|
|
|
|
|
|
|
{ |
33
|
|
|
|
|
|
|
template |
34
|
|
|
|
|
|
|
struct semiregular_move_assign |
35
|
|
|
|
|
|
|
: optional |
36
|
|
|
|
|
|
|
{ |
37
|
1276
|
|
|
|
|
|
using optional::optional; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
semiregular_move_assign() = default; |
40
|
|
|
|
|
|
|
semiregular_move_assign(semiregular_move_assign const &) = default; |
41
|
|
|
|
|
|
|
semiregular_move_assign(semiregular_move_assign &&) = default; |
42
|
|
|
|
|
|
|
semiregular_move_assign &operator=(semiregular_move_assign const &) = default; |
43
|
|
|
|
|
|
|
RANGES_CXX14_CONSTEXPR |
44
|
|
|
|
|
|
|
semiregular_move_assign &operator=(semiregular_move_assign &&that) |
45
|
|
|
|
|
|
|
noexcept(std::is_nothrow_move_constructible::value) |
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
this->reset(); |
48
|
|
|
|
|
|
|
if (that) |
49
|
|
|
|
|
|
|
this->emplace(detail::move(*that)); |
50
|
|
|
|
|
|
|
return *this; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
}; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
template |
55
|
|
|
|
|
|
|
using semiregular_move_layer = |
56
|
|
|
|
|
|
|
meta::if_, optional, semiregular_move_assign>; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
template |
59
|
|
|
|
|
|
|
struct semiregular_copy_assign |
60
|
|
|
|
|
|
|
: semiregular_move_layer |
61
|
|
|
|
|
|
|
{ |
62
|
1276
|
|
|
|
|
|
using semiregular_move_layer::semiregular_move_layer; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
semiregular_copy_assign() = default; |
65
|
|
|
|
|
|
|
semiregular_copy_assign(semiregular_copy_assign const &) = default; |
66
|
|
|
|
|
|
|
semiregular_copy_assign(semiregular_copy_assign &&) = default; |
67
|
|
|
|
|
|
|
RANGES_CXX14_CONSTEXPR |
68
|
|
|
|
|
|
|
semiregular_copy_assign &operator=(semiregular_copy_assign const &that) |
69
|
|
|
|
|
|
|
noexcept(std::is_nothrow_copy_constructible::value) |
70
|
|
|
|
|
|
|
{ |
71
|
|
|
|
|
|
|
this->reset(); |
72
|
|
|
|
|
|
|
if (that) |
73
|
|
|
|
|
|
|
this->emplace(*that); |
74
|
|
|
|
|
|
|
return *this; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
semiregular_copy_assign &operator=(semiregular_copy_assign &&) = default; |
77
|
|
|
|
|
|
|
}; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
template |
80
|
|
|
|
|
|
|
using semiregular_copy_layer = |
81
|
|
|
|
|
|
|
meta::if_, optional, semiregular_copy_assign>; |
82
|
|
|
|
|
|
|
} // namespace detail |
83
|
|
|
|
|
|
|
/// \endcond |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
template |
86
|
|
|
|
|
|
|
struct semiregular |
87
|
|
|
|
|
|
|
: detail::semiregular_copy_layer |
88
|
|
|
|
|
|
|
{ |
89
|
1276
|
|
|
|
|
|
using detail::semiregular_copy_layer::semiregular_copy_layer; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
constexpr semiregular() |
92
|
|
|
|
|
|
|
noexcept(std::is_nothrow_default_constructible::value || |
93
|
|
|
|
|
|
|
!std::is_default_constructible::value) |
94
|
|
|
|
|
|
|
: semiregular(tag{}, std::is_default_constructible{}) |
95
|
|
|
|
|
|
|
{} |
96
|
|
|
|
|
|
|
RANGES_CXX14_CONSTEXPR T &get() & noexcept |
97
|
|
|
|
|
|
|
{ |
98
|
|
|
|
|
|
|
return **this; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
constexpr T const &get() const & noexcept |
101
|
|
|
|
|
|
|
{ |
102
|
|
|
|
|
|
|
return **this; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
RANGES_CXX14_CONSTEXPR T &&get() && noexcept |
105
|
|
|
|
|
|
|
{ |
106
|
|
|
|
|
|
|
return *detail::move(*this); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
constexpr T const &&get() const && noexcept |
109
|
|
|
|
|
|
|
{ |
110
|
|
|
|
|
|
|
return *detail::move(*this); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
RANGES_CXX14_CONSTEXPR operator T &() & noexcept |
113
|
|
|
|
|
|
|
{ |
114
|
|
|
|
|
|
|
return **this; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
constexpr operator T const &() const & noexcept |
117
|
|
|
|
|
|
|
{ |
118
|
|
|
|
|
|
|
return **this; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
RANGES_CXX14_CONSTEXPR operator T &&() && noexcept |
121
|
|
|
|
|
|
|
{ |
122
|
|
|
|
|
|
|
return *detail::move(*this); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
constexpr operator T const &&() const && noexcept |
125
|
|
|
|
|
|
|
{ |
126
|
|
|
|
|
|
|
return *detail::move(*this); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
template |
129
|
3286
|
|
|
|
|
|
RANGES_CXX14_CONSTEXPR auto operator()(Args &&...args) & |
130
|
|
|
|
|
|
|
RANGES_DECLTYPE_NOEXCEPT(std::declval()(static_cast(args)...)) |
131
|
|
|
|
|
|
|
{ |
132
|
3286
|
|
|
|
|
|
return (**this)(static_cast(args)...); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
template |
135
|
|
|
|
|
|
|
constexpr auto operator()(Args &&...args) const & |
136
|
|
|
|
|
|
|
RANGES_DECLTYPE_NOEXCEPT(std::declval()(static_cast(args)...)) |
137
|
|
|
|
|
|
|
{ |
138
|
|
|
|
|
|
|
return (**this)(static_cast(args)...); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
template |
141
|
|
|
|
|
|
|
RANGES_CXX14_CONSTEXPR auto operator()(Args &&...args) && |
142
|
|
|
|
|
|
|
RANGES_DECLTYPE_NOEXCEPT(std::declval()(static_cast(args)...)) |
143
|
|
|
|
|
|
|
{ |
144
|
|
|
|
|
|
|
return (*detail::move(*this))(static_cast(args)...); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
template |
147
|
|
|
|
|
|
|
constexpr auto operator()(Args &&...args) const && |
148
|
|
|
|
|
|
|
RANGES_DECLTYPE_NOEXCEPT(std::declval()(static_cast(args)...)) |
149
|
|
|
|
|
|
|
{ |
150
|
|
|
|
|
|
|
return (*detail::move(*this))(static_cast(args)...); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
private: |
153
|
|
|
|
|
|
|
struct tag {}; |
154
|
|
|
|
|
|
|
constexpr semiregular(tag, std::false_type) noexcept |
155
|
|
|
|
|
|
|
{} |
156
|
|
|
|
|
|
|
constexpr semiregular(tag, std::true_type) |
157
|
|
|
|
|
|
|
noexcept(std::is_nothrow_default_constructible::value) |
158
|
|
|
|
|
|
|
: detail::semiregular_copy_layer{in_place} |
159
|
|
|
|
|
|
|
{} |
160
|
|
|
|
|
|
|
}; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
template |
163
|
|
|
|
|
|
|
struct semiregular |
164
|
|
|
|
|
|
|
: private ranges::reference_wrapper |
165
|
|
|
|
|
|
|
{ |
166
|
|
|
|
|
|
|
semiregular() = default; |
167
|
|
|
|
|
|
|
template
|
168
|
|
|
|
|
|
|
CONCEPT_REQUIRES_(Constructible, Arg &>())> |
169
|
|
|
|
|
|
|
semiregular(in_place_t, Arg &arg) |
170
|
|
|
|
|
|
|
: ranges::reference_wrapper(arg) |
171
|
|
|
|
|
|
|
{} |
172
|
|
|
|
|
|
|
using ranges::reference_wrapper::reference_wrapper; |
173
|
|
|
|
|
|
|
using ranges::reference_wrapper::get; |
174
|
|
|
|
|
|
|
using ranges::reference_wrapper::operator T &; |
175
|
|
|
|
|
|
|
using ranges::reference_wrapper::operator(); |
176
|
|
|
|
|
|
|
}; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
template |
179
|
|
|
|
|
|
|
struct semiregular |
180
|
|
|
|
|
|
|
: private ranges::reference_wrapper |
181
|
|
|
|
|
|
|
{ |
182
|
|
|
|
|
|
|
semiregular() = default; |
183
|
|
|
|
|
|
|
template
|
184
|
|
|
|
|
|
|
CONCEPT_REQUIRES_(Constructible, Arg>())> |
185
|
|
|
|
|
|
|
semiregular(in_place_t, Arg &&arg) |
186
|
|
|
|
|
|
|
: ranges::reference_wrapper(static_cast(arg)) |
187
|
|
|
|
|
|
|
{} |
188
|
|
|
|
|
|
|
using ranges::reference_wrapper::reference_wrapper; |
189
|
|
|
|
|
|
|
using ranges::reference_wrapper::get; |
190
|
|
|
|
|
|
|
using ranges::reference_wrapper::operator T &&; |
191
|
|
|
|
|
|
|
using ranges::reference_wrapper::operator(); |
192
|
|
|
|
|
|
|
}; |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
template |
195
|
|
|
|
|
|
|
using semiregular_t = |
196
|
|
|
|
|
|
|
meta::if_, T, semiregular>; |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
template |
199
|
|
|
|
|
|
|
using movesemiregular_t = |
200
|
|
|
|
|
|
|
meta::if_c< |
201
|
|
|
|
|
|
|
Movable() && DefaultConstructible(), |
202
|
|
|
|
|
|
|
T, |
203
|
|
|
|
|
|
|
semiregular>; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
template |
206
|
|
|
|
|
|
|
using semiregular_ref_or_val_t = |
207
|
|
|
|
|
|
|
meta::if_< |
208
|
|
|
|
|
|
|
SemiRegular, |
209
|
|
|
|
|
|
|
meta::if_c>, |
210
|
|
|
|
|
|
|
reference_wrapper const, semiregular>>>; |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
template |
213
|
|
|
|
|
|
|
auto get(meta::id_t> &t) |
214
|
|
|
|
|
|
|
RANGES_DECLTYPE_AUTO_RETURN_NOEXCEPT |
215
|
|
|
|
|
|
|
( |
216
|
|
|
|
|
|
|
t.get() |
217
|
|
|
|
|
|
|
) |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
template |
220
|
|
|
|
|
|
|
auto get(meta::id_t> const &t) |
221
|
|
|
|
|
|
|
RANGES_DECLTYPE_AUTO_RETURN_NOEXCEPT |
222
|
|
|
|
|
|
|
( |
223
|
|
|
|
|
|
|
t.get() |
224
|
|
|
|
|
|
|
) |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
template |
227
|
|
|
|
|
|
|
auto get(meta::id_t> &&t) |
228
|
|
|
|
|
|
|
RANGES_DECLTYPE_AUTO_RETURN_NOEXCEPT |
229
|
|
|
|
|
|
|
( |
230
|
|
|
|
|
|
|
detail::move(t).get() |
231
|
|
|
|
|
|
|
) |
232
|
|
|
|
|
|
|
/// @} |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
#endif |