annotate libcxx/include/__functional_base @ 221:79ff65ed7e25

LLVM12 Original
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 15 Jun 2021 19:15:29 +0900
parents 0572611fdcc8
children 5f17cb93ff66
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // -*- C++ -*-
anatofuz
parents:
diff changeset
2 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
3 //
anatofuz
parents:
diff changeset
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
5 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
7 //
anatofuz
parents:
diff changeset
8 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 #ifndef _LIBCPP_FUNCTIONAL_BASE
anatofuz
parents:
diff changeset
11 #define _LIBCPP_FUNCTIONAL_BASE
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 #include <__config>
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
14 #include <exception>
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
15 #include <new>
150
anatofuz
parents:
diff changeset
16 #include <type_traits>
anatofuz
parents:
diff changeset
17 #include <typeinfo>
anatofuz
parents:
diff changeset
18 #include <utility>
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
anatofuz
parents:
diff changeset
21 #pragma GCC system_header
anatofuz
parents:
diff changeset
22 #endif
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 _LIBCPP_BEGIN_NAMESPACE_STD
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 template <class _Arg1, class _Arg2, class _Result>
anatofuz
parents:
diff changeset
27 struct _LIBCPP_TEMPLATE_VIS binary_function
anatofuz
parents:
diff changeset
28 {
anatofuz
parents:
diff changeset
29 typedef _Arg1 first_argument_type;
anatofuz
parents:
diff changeset
30 typedef _Arg2 second_argument_type;
anatofuz
parents:
diff changeset
31 typedef _Result result_type;
anatofuz
parents:
diff changeset
32 };
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 template <class _Tp>
anatofuz
parents:
diff changeset
35 struct __has_result_type
anatofuz
parents:
diff changeset
36 {
anatofuz
parents:
diff changeset
37 private:
anatofuz
parents:
diff changeset
38 struct __two {char __lx; char __lxx;};
anatofuz
parents:
diff changeset
39 template <class _Up> static __two __test(...);
anatofuz
parents:
diff changeset
40 template <class _Up> static char __test(typename _Up::result_type* = 0);
anatofuz
parents:
diff changeset
41 public:
anatofuz
parents:
diff changeset
42 static const bool value = sizeof(__test<_Tp>(0)) == 1;
anatofuz
parents:
diff changeset
43 };
anatofuz
parents:
diff changeset
44
anatofuz
parents:
diff changeset
45 #if _LIBCPP_STD_VER > 11
anatofuz
parents:
diff changeset
46 template <class _Tp = void>
anatofuz
parents:
diff changeset
47 #else
anatofuz
parents:
diff changeset
48 template <class _Tp>
anatofuz
parents:
diff changeset
49 #endif
anatofuz
parents:
diff changeset
50 struct _LIBCPP_TEMPLATE_VIS less : binary_function<_Tp, _Tp, bool>
anatofuz
parents:
diff changeset
51 {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
52 typedef bool __result_type; // used by valarray
150
anatofuz
parents:
diff changeset
53 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
54 bool operator()(const _Tp& __x, const _Tp& __y) const
anatofuz
parents:
diff changeset
55 {return __x < __y;}
anatofuz
parents:
diff changeset
56 };
anatofuz
parents:
diff changeset
57
anatofuz
parents:
diff changeset
58 #if _LIBCPP_STD_VER > 11
anatofuz
parents:
diff changeset
59 template <>
anatofuz
parents:
diff changeset
60 struct _LIBCPP_TEMPLATE_VIS less<void>
anatofuz
parents:
diff changeset
61 {
anatofuz
parents:
diff changeset
62 template <class _T1, class _T2>
anatofuz
parents:
diff changeset
63 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
64 auto operator()(_T1&& __t, _T2&& __u) const
anatofuz
parents:
diff changeset
65 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))
anatofuz
parents:
diff changeset
66 -> decltype (_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))
anatofuz
parents:
diff changeset
67 { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
anatofuz
parents:
diff changeset
68 typedef void is_transparent;
anatofuz
parents:
diff changeset
69 };
anatofuz
parents:
diff changeset
70 #endif
anatofuz
parents:
diff changeset
71
anatofuz
parents:
diff changeset
72 // __weak_result_type
anatofuz
parents:
diff changeset
73
anatofuz
parents:
diff changeset
74 template <class _Tp>
anatofuz
parents:
diff changeset
75 struct __derives_from_unary_function
anatofuz
parents:
diff changeset
76 {
anatofuz
parents:
diff changeset
77 private:
anatofuz
parents:
diff changeset
78 struct __two {char __lx; char __lxx;};
anatofuz
parents:
diff changeset
79 static __two __test(...);
anatofuz
parents:
diff changeset
80 template <class _Ap, class _Rp>
anatofuz
parents:
diff changeset
81 static unary_function<_Ap, _Rp>
anatofuz
parents:
diff changeset
82 __test(const volatile unary_function<_Ap, _Rp>*);
anatofuz
parents:
diff changeset
83 public:
anatofuz
parents:
diff changeset
84 static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
anatofuz
parents:
diff changeset
85 typedef decltype(__test((_Tp*)0)) type;
anatofuz
parents:
diff changeset
86 };
anatofuz
parents:
diff changeset
87
anatofuz
parents:
diff changeset
88 template <class _Tp>
anatofuz
parents:
diff changeset
89 struct __derives_from_binary_function
anatofuz
parents:
diff changeset
90 {
anatofuz
parents:
diff changeset
91 private:
anatofuz
parents:
diff changeset
92 struct __two {char __lx; char __lxx;};
anatofuz
parents:
diff changeset
93 static __two __test(...);
anatofuz
parents:
diff changeset
94 template <class _A1, class _A2, class _Rp>
anatofuz
parents:
diff changeset
95 static binary_function<_A1, _A2, _Rp>
anatofuz
parents:
diff changeset
96 __test(const volatile binary_function<_A1, _A2, _Rp>*);
anatofuz
parents:
diff changeset
97 public:
anatofuz
parents:
diff changeset
98 static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
anatofuz
parents:
diff changeset
99 typedef decltype(__test((_Tp*)0)) type;
anatofuz
parents:
diff changeset
100 };
anatofuz
parents:
diff changeset
101
anatofuz
parents:
diff changeset
102 template <class _Tp, bool = __derives_from_unary_function<_Tp>::value>
anatofuz
parents:
diff changeset
103 struct __maybe_derive_from_unary_function // bool is true
anatofuz
parents:
diff changeset
104 : public __derives_from_unary_function<_Tp>::type
anatofuz
parents:
diff changeset
105 {
anatofuz
parents:
diff changeset
106 };
anatofuz
parents:
diff changeset
107
anatofuz
parents:
diff changeset
108 template <class _Tp>
anatofuz
parents:
diff changeset
109 struct __maybe_derive_from_unary_function<_Tp, false>
anatofuz
parents:
diff changeset
110 {
anatofuz
parents:
diff changeset
111 };
anatofuz
parents:
diff changeset
112
anatofuz
parents:
diff changeset
113 template <class _Tp, bool = __derives_from_binary_function<_Tp>::value>
anatofuz
parents:
diff changeset
114 struct __maybe_derive_from_binary_function // bool is true
anatofuz
parents:
diff changeset
115 : public __derives_from_binary_function<_Tp>::type
anatofuz
parents:
diff changeset
116 {
anatofuz
parents:
diff changeset
117 };
anatofuz
parents:
diff changeset
118
anatofuz
parents:
diff changeset
119 template <class _Tp>
anatofuz
parents:
diff changeset
120 struct __maybe_derive_from_binary_function<_Tp, false>
anatofuz
parents:
diff changeset
121 {
anatofuz
parents:
diff changeset
122 };
anatofuz
parents:
diff changeset
123
anatofuz
parents:
diff changeset
124 template <class _Tp, bool = __has_result_type<_Tp>::value>
anatofuz
parents:
diff changeset
125 struct __weak_result_type_imp // bool is true
anatofuz
parents:
diff changeset
126 : public __maybe_derive_from_unary_function<_Tp>,
anatofuz
parents:
diff changeset
127 public __maybe_derive_from_binary_function<_Tp>
anatofuz
parents:
diff changeset
128 {
anatofuz
parents:
diff changeset
129 typedef _LIBCPP_NODEBUG_TYPE typename _Tp::result_type result_type;
anatofuz
parents:
diff changeset
130 };
anatofuz
parents:
diff changeset
131
anatofuz
parents:
diff changeset
132 template <class _Tp>
anatofuz
parents:
diff changeset
133 struct __weak_result_type_imp<_Tp, false>
anatofuz
parents:
diff changeset
134 : public __maybe_derive_from_unary_function<_Tp>,
anatofuz
parents:
diff changeset
135 public __maybe_derive_from_binary_function<_Tp>
anatofuz
parents:
diff changeset
136 {
anatofuz
parents:
diff changeset
137 };
anatofuz
parents:
diff changeset
138
anatofuz
parents:
diff changeset
139 template <class _Tp>
anatofuz
parents:
diff changeset
140 struct __weak_result_type
anatofuz
parents:
diff changeset
141 : public __weak_result_type_imp<_Tp>
anatofuz
parents:
diff changeset
142 {
anatofuz
parents:
diff changeset
143 };
anatofuz
parents:
diff changeset
144
anatofuz
parents:
diff changeset
145 // 0 argument case
anatofuz
parents:
diff changeset
146
anatofuz
parents:
diff changeset
147 template <class _Rp>
anatofuz
parents:
diff changeset
148 struct __weak_result_type<_Rp ()>
anatofuz
parents:
diff changeset
149 {
anatofuz
parents:
diff changeset
150 typedef _LIBCPP_NODEBUG_TYPE _Rp result_type;
anatofuz
parents:
diff changeset
151 };
anatofuz
parents:
diff changeset
152
anatofuz
parents:
diff changeset
153 template <class _Rp>
anatofuz
parents:
diff changeset
154 struct __weak_result_type<_Rp (&)()>
anatofuz
parents:
diff changeset
155 {
anatofuz
parents:
diff changeset
156 typedef _LIBCPP_NODEBUG_TYPE _Rp result_type;
anatofuz
parents:
diff changeset
157 };
anatofuz
parents:
diff changeset
158
anatofuz
parents:
diff changeset
159 template <class _Rp>
anatofuz
parents:
diff changeset
160 struct __weak_result_type<_Rp (*)()>
anatofuz
parents:
diff changeset
161 {
anatofuz
parents:
diff changeset
162 typedef _LIBCPP_NODEBUG_TYPE _Rp result_type;
anatofuz
parents:
diff changeset
163 };
anatofuz
parents:
diff changeset
164
anatofuz
parents:
diff changeset
165 // 1 argument case
anatofuz
parents:
diff changeset
166
anatofuz
parents:
diff changeset
167 template <class _Rp, class _A1>
anatofuz
parents:
diff changeset
168 struct __weak_result_type<_Rp (_A1)>
anatofuz
parents:
diff changeset
169 : public unary_function<_A1, _Rp>
anatofuz
parents:
diff changeset
170 {
anatofuz
parents:
diff changeset
171 };
anatofuz
parents:
diff changeset
172
anatofuz
parents:
diff changeset
173 template <class _Rp, class _A1>
anatofuz
parents:
diff changeset
174 struct __weak_result_type<_Rp (&)(_A1)>
anatofuz
parents:
diff changeset
175 : public unary_function<_A1, _Rp>
anatofuz
parents:
diff changeset
176 {
anatofuz
parents:
diff changeset
177 };
anatofuz
parents:
diff changeset
178
anatofuz
parents:
diff changeset
179 template <class _Rp, class _A1>
anatofuz
parents:
diff changeset
180 struct __weak_result_type<_Rp (*)(_A1)>
anatofuz
parents:
diff changeset
181 : public unary_function<_A1, _Rp>
anatofuz
parents:
diff changeset
182 {
anatofuz
parents:
diff changeset
183 };
anatofuz
parents:
diff changeset
184
anatofuz
parents:
diff changeset
185 template <class _Rp, class _Cp>
anatofuz
parents:
diff changeset
186 struct __weak_result_type<_Rp (_Cp::*)()>
anatofuz
parents:
diff changeset
187 : public unary_function<_Cp*, _Rp>
anatofuz
parents:
diff changeset
188 {
anatofuz
parents:
diff changeset
189 };
anatofuz
parents:
diff changeset
190
anatofuz
parents:
diff changeset
191 template <class _Rp, class _Cp>
anatofuz
parents:
diff changeset
192 struct __weak_result_type<_Rp (_Cp::*)() const>
anatofuz
parents:
diff changeset
193 : public unary_function<const _Cp*, _Rp>
anatofuz
parents:
diff changeset
194 {
anatofuz
parents:
diff changeset
195 };
anatofuz
parents:
diff changeset
196
anatofuz
parents:
diff changeset
197 template <class _Rp, class _Cp>
anatofuz
parents:
diff changeset
198 struct __weak_result_type<_Rp (_Cp::*)() volatile>
anatofuz
parents:
diff changeset
199 : public unary_function<volatile _Cp*, _Rp>
anatofuz
parents:
diff changeset
200 {
anatofuz
parents:
diff changeset
201 };
anatofuz
parents:
diff changeset
202
anatofuz
parents:
diff changeset
203 template <class _Rp, class _Cp>
anatofuz
parents:
diff changeset
204 struct __weak_result_type<_Rp (_Cp::*)() const volatile>
anatofuz
parents:
diff changeset
205 : public unary_function<const volatile _Cp*, _Rp>
anatofuz
parents:
diff changeset
206 {
anatofuz
parents:
diff changeset
207 };
anatofuz
parents:
diff changeset
208
anatofuz
parents:
diff changeset
209 // 2 argument case
anatofuz
parents:
diff changeset
210
anatofuz
parents:
diff changeset
211 template <class _Rp, class _A1, class _A2>
anatofuz
parents:
diff changeset
212 struct __weak_result_type<_Rp (_A1, _A2)>
anatofuz
parents:
diff changeset
213 : public binary_function<_A1, _A2, _Rp>
anatofuz
parents:
diff changeset
214 {
anatofuz
parents:
diff changeset
215 };
anatofuz
parents:
diff changeset
216
anatofuz
parents:
diff changeset
217 template <class _Rp, class _A1, class _A2>
anatofuz
parents:
diff changeset
218 struct __weak_result_type<_Rp (*)(_A1, _A2)>
anatofuz
parents:
diff changeset
219 : public binary_function<_A1, _A2, _Rp>
anatofuz
parents:
diff changeset
220 {
anatofuz
parents:
diff changeset
221 };
anatofuz
parents:
diff changeset
222
anatofuz
parents:
diff changeset
223 template <class _Rp, class _A1, class _A2>
anatofuz
parents:
diff changeset
224 struct __weak_result_type<_Rp (&)(_A1, _A2)>
anatofuz
parents:
diff changeset
225 : public binary_function<_A1, _A2, _Rp>
anatofuz
parents:
diff changeset
226 {
anatofuz
parents:
diff changeset
227 };
anatofuz
parents:
diff changeset
228
anatofuz
parents:
diff changeset
229 template <class _Rp, class _Cp, class _A1>
anatofuz
parents:
diff changeset
230 struct __weak_result_type<_Rp (_Cp::*)(_A1)>
anatofuz
parents:
diff changeset
231 : public binary_function<_Cp*, _A1, _Rp>
anatofuz
parents:
diff changeset
232 {
anatofuz
parents:
diff changeset
233 };
anatofuz
parents:
diff changeset
234
anatofuz
parents:
diff changeset
235 template <class _Rp, class _Cp, class _A1>
anatofuz
parents:
diff changeset
236 struct __weak_result_type<_Rp (_Cp::*)(_A1) const>
anatofuz
parents:
diff changeset
237 : public binary_function<const _Cp*, _A1, _Rp>
anatofuz
parents:
diff changeset
238 {
anatofuz
parents:
diff changeset
239 };
anatofuz
parents:
diff changeset
240
anatofuz
parents:
diff changeset
241 template <class _Rp, class _Cp, class _A1>
anatofuz
parents:
diff changeset
242 struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile>
anatofuz
parents:
diff changeset
243 : public binary_function<volatile _Cp*, _A1, _Rp>
anatofuz
parents:
diff changeset
244 {
anatofuz
parents:
diff changeset
245 };
anatofuz
parents:
diff changeset
246
anatofuz
parents:
diff changeset
247 template <class _Rp, class _Cp, class _A1>
anatofuz
parents:
diff changeset
248 struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>
anatofuz
parents:
diff changeset
249 : public binary_function<const volatile _Cp*, _A1, _Rp>
anatofuz
parents:
diff changeset
250 {
anatofuz
parents:
diff changeset
251 };
anatofuz
parents:
diff changeset
252
anatofuz
parents:
diff changeset
253
anatofuz
parents:
diff changeset
254 #ifndef _LIBCPP_CXX03_LANG
anatofuz
parents:
diff changeset
255 // 3 or more arguments
anatofuz
parents:
diff changeset
256
anatofuz
parents:
diff changeset
257 template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
anatofuz
parents:
diff changeset
258 struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)>
anatofuz
parents:
diff changeset
259 {
anatofuz
parents:
diff changeset
260 typedef _Rp result_type;
anatofuz
parents:
diff changeset
261 };
anatofuz
parents:
diff changeset
262
anatofuz
parents:
diff changeset
263 template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
anatofuz
parents:
diff changeset
264 struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)>
anatofuz
parents:
diff changeset
265 {
anatofuz
parents:
diff changeset
266 typedef _Rp result_type;
anatofuz
parents:
diff changeset
267 };
anatofuz
parents:
diff changeset
268
anatofuz
parents:
diff changeset
269 template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
anatofuz
parents:
diff changeset
270 struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)>
anatofuz
parents:
diff changeset
271 {
anatofuz
parents:
diff changeset
272 typedef _Rp result_type;
anatofuz
parents:
diff changeset
273 };
anatofuz
parents:
diff changeset
274
anatofuz
parents:
diff changeset
275 template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
anatofuz
parents:
diff changeset
276 struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)>
anatofuz
parents:
diff changeset
277 {
anatofuz
parents:
diff changeset
278 typedef _Rp result_type;
anatofuz
parents:
diff changeset
279 };
anatofuz
parents:
diff changeset
280
anatofuz
parents:
diff changeset
281 template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
anatofuz
parents:
diff changeset
282 struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const>
anatofuz
parents:
diff changeset
283 {
anatofuz
parents:
diff changeset
284 typedef _Rp result_type;
anatofuz
parents:
diff changeset
285 };
anatofuz
parents:
diff changeset
286
anatofuz
parents:
diff changeset
287 template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
anatofuz
parents:
diff changeset
288 struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile>
anatofuz
parents:
diff changeset
289 {
anatofuz
parents:
diff changeset
290 typedef _Rp result_type;
anatofuz
parents:
diff changeset
291 };
anatofuz
parents:
diff changeset
292
anatofuz
parents:
diff changeset
293 template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
anatofuz
parents:
diff changeset
294 struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
anatofuz
parents:
diff changeset
295 {
anatofuz
parents:
diff changeset
296 typedef _Rp result_type;
anatofuz
parents:
diff changeset
297 };
anatofuz
parents:
diff changeset
298
anatofuz
parents:
diff changeset
299 template <class _Tp, class ..._Args>
anatofuz
parents:
diff changeset
300 struct __invoke_return
anatofuz
parents:
diff changeset
301 {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
302 typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type;
150
anatofuz
parents:
diff changeset
303 };
anatofuz
parents:
diff changeset
304
anatofuz
parents:
diff changeset
305 #else // defined(_LIBCPP_CXX03_LANG)
anatofuz
parents:
diff changeset
306
anatofuz
parents:
diff changeset
307 #include <__functional_base_03>
anatofuz
parents:
diff changeset
308
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
309 #endif // !defined(_LIBCPP_CXX03_LANG)
150
anatofuz
parents:
diff changeset
310
anatofuz
parents:
diff changeset
311
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
312 template <class _Ret, bool = is_void<_Ret>::value>
150
anatofuz
parents:
diff changeset
313 struct __invoke_void_return_wrapper
anatofuz
parents:
diff changeset
314 {
anatofuz
parents:
diff changeset
315 #ifndef _LIBCPP_CXX03_LANG
anatofuz
parents:
diff changeset
316 template <class ..._Args>
anatofuz
parents:
diff changeset
317 static _Ret __call(_Args&&... __args) {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
318 return _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
150
anatofuz
parents:
diff changeset
319 }
anatofuz
parents:
diff changeset
320 #else
anatofuz
parents:
diff changeset
321 template <class _Fn>
anatofuz
parents:
diff changeset
322 static _Ret __call(_Fn __f) {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
323 return _VSTD::__invoke(__f);
150
anatofuz
parents:
diff changeset
324 }
anatofuz
parents:
diff changeset
325
anatofuz
parents:
diff changeset
326 template <class _Fn, class _A0>
anatofuz
parents:
diff changeset
327 static _Ret __call(_Fn __f, _A0& __a0) {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
328 return _VSTD::__invoke(__f, __a0);
150
anatofuz
parents:
diff changeset
329 }
anatofuz
parents:
diff changeset
330
anatofuz
parents:
diff changeset
331 template <class _Fn, class _A0, class _A1>
anatofuz
parents:
diff changeset
332 static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
333 return _VSTD::__invoke(__f, __a0, __a1);
150
anatofuz
parents:
diff changeset
334 }
anatofuz
parents:
diff changeset
335
anatofuz
parents:
diff changeset
336 template <class _Fn, class _A0, class _A1, class _A2>
anatofuz
parents:
diff changeset
337 static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
338 return _VSTD::__invoke(__f, __a0, __a1, __a2);
150
anatofuz
parents:
diff changeset
339 }
anatofuz
parents:
diff changeset
340 #endif
anatofuz
parents:
diff changeset
341 };
anatofuz
parents:
diff changeset
342
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
343 template <class _Ret>
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
344 struct __invoke_void_return_wrapper<_Ret, true>
150
anatofuz
parents:
diff changeset
345 {
anatofuz
parents:
diff changeset
346 #ifndef _LIBCPP_CXX03_LANG
anatofuz
parents:
diff changeset
347 template <class ..._Args>
anatofuz
parents:
diff changeset
348 static void __call(_Args&&... __args) {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
349 _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
150
anatofuz
parents:
diff changeset
350 }
anatofuz
parents:
diff changeset
351 #else
anatofuz
parents:
diff changeset
352 template <class _Fn>
anatofuz
parents:
diff changeset
353 static void __call(_Fn __f) {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
354 _VSTD::__invoke(__f);
150
anatofuz
parents:
diff changeset
355 }
anatofuz
parents:
diff changeset
356
anatofuz
parents:
diff changeset
357 template <class _Fn, class _A0>
anatofuz
parents:
diff changeset
358 static void __call(_Fn __f, _A0& __a0) {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
359 _VSTD::__invoke(__f, __a0);
150
anatofuz
parents:
diff changeset
360 }
anatofuz
parents:
diff changeset
361
anatofuz
parents:
diff changeset
362 template <class _Fn, class _A0, class _A1>
anatofuz
parents:
diff changeset
363 static void __call(_Fn __f, _A0& __a0, _A1& __a1) {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
364 _VSTD::__invoke(__f, __a0, __a1);
150
anatofuz
parents:
diff changeset
365 }
anatofuz
parents:
diff changeset
366
anatofuz
parents:
diff changeset
367 template <class _Fn, class _A0, class _A1, class _A2>
anatofuz
parents:
diff changeset
368 static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
369 _VSTD::__invoke(__f, __a0, __a1, __a2);
150
anatofuz
parents:
diff changeset
370 }
anatofuz
parents:
diff changeset
371 #endif
anatofuz
parents:
diff changeset
372 };
anatofuz
parents:
diff changeset
373
anatofuz
parents:
diff changeset
374 template <class _Tp>
anatofuz
parents:
diff changeset
375 class _LIBCPP_TEMPLATE_VIS reference_wrapper
anatofuz
parents:
diff changeset
376 : public __weak_result_type<_Tp>
anatofuz
parents:
diff changeset
377 {
anatofuz
parents:
diff changeset
378 public:
anatofuz
parents:
diff changeset
379 // types
anatofuz
parents:
diff changeset
380 typedef _Tp type;
anatofuz
parents:
diff changeset
381 private:
anatofuz
parents:
diff changeset
382 type* __f_;
anatofuz
parents:
diff changeset
383
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
384 #ifndef _LIBCPP_CXX03_LANG
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
385 static void __fun(_Tp&) _NOEXCEPT;
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
386 static void __fun(_Tp&&) = delete;
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
387 #endif
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
388
150
anatofuz
parents:
diff changeset
389 public:
anatofuz
parents:
diff changeset
390 // construct/copy/destroy
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
391 #ifdef _LIBCPP_CXX03_LANG
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
392 _LIBCPP_INLINE_VISIBILITY
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
393 reference_wrapper(type& __f) _NOEXCEPT
150
anatofuz
parents:
diff changeset
394 : __f_(_VSTD::addressof(__f)) {}
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
395 #else
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
396 template <class _Up, class = _EnableIf<!__is_same_uncvref<_Up, reference_wrapper>::value, decltype(__fun(declval<_Up>())) >>
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
397 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
398 reference_wrapper(_Up&& __u) _NOEXCEPT_(noexcept(__fun(declval<_Up>()))) {
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
399 type& __f = static_cast<_Up&&>(__u);
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
400 __f_ = _VSTD::addressof(__f);
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
401 }
150
anatofuz
parents:
diff changeset
402 #endif
anatofuz
parents:
diff changeset
403
anatofuz
parents:
diff changeset
404 // access
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
405 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
406 operator type&() const _NOEXCEPT {return *__f_;}
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
407 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
408 type& get() const _NOEXCEPT {return *__f_;}
150
anatofuz
parents:
diff changeset
409
anatofuz
parents:
diff changeset
410 #ifndef _LIBCPP_CXX03_LANG
anatofuz
parents:
diff changeset
411 // invoke
anatofuz
parents:
diff changeset
412 template <class... _ArgTypes>
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
413 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
150
anatofuz
parents:
diff changeset
414 typename __invoke_of<type&, _ArgTypes...>::type
anatofuz
parents:
diff changeset
415 operator() (_ArgTypes&&... __args) const {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
416 return _VSTD::__invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
150
anatofuz
parents:
diff changeset
417 }
anatofuz
parents:
diff changeset
418 #else
anatofuz
parents:
diff changeset
419
anatofuz
parents:
diff changeset
420 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
421 typename __invoke_return<type>::type
anatofuz
parents:
diff changeset
422 operator() () const {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
423 return _VSTD::__invoke(get());
150
anatofuz
parents:
diff changeset
424 }
anatofuz
parents:
diff changeset
425
anatofuz
parents:
diff changeset
426 template <class _A0>
anatofuz
parents:
diff changeset
427 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
428 typename __invoke_return0<type, _A0>::type
anatofuz
parents:
diff changeset
429 operator() (_A0& __a0) const {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
430 return _VSTD::__invoke(get(), __a0);
150
anatofuz
parents:
diff changeset
431 }
anatofuz
parents:
diff changeset
432
anatofuz
parents:
diff changeset
433 template <class _A0>
anatofuz
parents:
diff changeset
434 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
435 typename __invoke_return0<type, _A0 const>::type
anatofuz
parents:
diff changeset
436 operator() (_A0 const& __a0) const {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
437 return _VSTD::__invoke(get(), __a0);
150
anatofuz
parents:
diff changeset
438 }
anatofuz
parents:
diff changeset
439
anatofuz
parents:
diff changeset
440 template <class _A0, class _A1>
anatofuz
parents:
diff changeset
441 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
442 typename __invoke_return1<type, _A0, _A1>::type
anatofuz
parents:
diff changeset
443 operator() (_A0& __a0, _A1& __a1) const {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
444 return _VSTD::__invoke(get(), __a0, __a1);
150
anatofuz
parents:
diff changeset
445 }
anatofuz
parents:
diff changeset
446
anatofuz
parents:
diff changeset
447 template <class _A0, class _A1>
anatofuz
parents:
diff changeset
448 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
449 typename __invoke_return1<type, _A0 const, _A1>::type
anatofuz
parents:
diff changeset
450 operator() (_A0 const& __a0, _A1& __a1) const {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
451 return _VSTD::__invoke(get(), __a0, __a1);
150
anatofuz
parents:
diff changeset
452 }
anatofuz
parents:
diff changeset
453
anatofuz
parents:
diff changeset
454 template <class _A0, class _A1>
anatofuz
parents:
diff changeset
455 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
456 typename __invoke_return1<type, _A0, _A1 const>::type
anatofuz
parents:
diff changeset
457 operator() (_A0& __a0, _A1 const& __a1) const {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
458 return _VSTD::__invoke(get(), __a0, __a1);
150
anatofuz
parents:
diff changeset
459 }
anatofuz
parents:
diff changeset
460
anatofuz
parents:
diff changeset
461 template <class _A0, class _A1>
anatofuz
parents:
diff changeset
462 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
463 typename __invoke_return1<type, _A0 const, _A1 const>::type
anatofuz
parents:
diff changeset
464 operator() (_A0 const& __a0, _A1 const& __a1) const {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
465 return _VSTD::__invoke(get(), __a0, __a1);
150
anatofuz
parents:
diff changeset
466 }
anatofuz
parents:
diff changeset
467
anatofuz
parents:
diff changeset
468 template <class _A0, class _A1, class _A2>
anatofuz
parents:
diff changeset
469 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
470 typename __invoke_return2<type, _A0, _A1, _A2>::type
anatofuz
parents:
diff changeset
471 operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
472 return _VSTD::__invoke(get(), __a0, __a1, __a2);
150
anatofuz
parents:
diff changeset
473 }
anatofuz
parents:
diff changeset
474
anatofuz
parents:
diff changeset
475 template <class _A0, class _A1, class _A2>
anatofuz
parents:
diff changeset
476 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
477 typename __invoke_return2<type, _A0 const, _A1, _A2>::type
anatofuz
parents:
diff changeset
478 operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
479 return _VSTD::__invoke(get(), __a0, __a1, __a2);
150
anatofuz
parents:
diff changeset
480 }
anatofuz
parents:
diff changeset
481
anatofuz
parents:
diff changeset
482 template <class _A0, class _A1, class _A2>
anatofuz
parents:
diff changeset
483 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
484 typename __invoke_return2<type, _A0, _A1 const, _A2>::type
anatofuz
parents:
diff changeset
485 operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
486 return _VSTD::__invoke(get(), __a0, __a1, __a2);
150
anatofuz
parents:
diff changeset
487 }
anatofuz
parents:
diff changeset
488
anatofuz
parents:
diff changeset
489 template <class _A0, class _A1, class _A2>
anatofuz
parents:
diff changeset
490 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
491 typename __invoke_return2<type, _A0, _A1, _A2 const>::type
anatofuz
parents:
diff changeset
492 operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
493 return _VSTD::__invoke(get(), __a0, __a1, __a2);
150
anatofuz
parents:
diff changeset
494 }
anatofuz
parents:
diff changeset
495
anatofuz
parents:
diff changeset
496 template <class _A0, class _A1, class _A2>
anatofuz
parents:
diff changeset
497 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
498 typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
anatofuz
parents:
diff changeset
499 operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
500 return _VSTD::__invoke(get(), __a0, __a1, __a2);
150
anatofuz
parents:
diff changeset
501 }
anatofuz
parents:
diff changeset
502
anatofuz
parents:
diff changeset
503 template <class _A0, class _A1, class _A2>
anatofuz
parents:
diff changeset
504 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
505 typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
anatofuz
parents:
diff changeset
506 operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
507 return _VSTD::__invoke(get(), __a0, __a1, __a2);
150
anatofuz
parents:
diff changeset
508 }
anatofuz
parents:
diff changeset
509
anatofuz
parents:
diff changeset
510 template <class _A0, class _A1, class _A2>
anatofuz
parents:
diff changeset
511 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
512 typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
anatofuz
parents:
diff changeset
513 operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
514 return _VSTD::__invoke(get(), __a0, __a1, __a2);
150
anatofuz
parents:
diff changeset
515 }
anatofuz
parents:
diff changeset
516
anatofuz
parents:
diff changeset
517 template <class _A0, class _A1, class _A2>
anatofuz
parents:
diff changeset
518 _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
519 typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
anatofuz
parents:
diff changeset
520 operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
521 return _VSTD::__invoke(get(), __a0, __a1, __a2);
150
anatofuz
parents:
diff changeset
522 }
anatofuz
parents:
diff changeset
523 #endif // _LIBCPP_CXX03_LANG
anatofuz
parents:
diff changeset
524 };
anatofuz
parents:
diff changeset
525
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
526 #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
527 template <class _Tp>
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
528 reference_wrapper(_Tp&) -> reference_wrapper<_Tp>;
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
529 #endif
150
anatofuz
parents:
diff changeset
530
anatofuz
parents:
diff changeset
531 template <class _Tp>
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
532 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
150
anatofuz
parents:
diff changeset
533 reference_wrapper<_Tp>
anatofuz
parents:
diff changeset
534 ref(_Tp& __t) _NOEXCEPT
anatofuz
parents:
diff changeset
535 {
anatofuz
parents:
diff changeset
536 return reference_wrapper<_Tp>(__t);
anatofuz
parents:
diff changeset
537 }
anatofuz
parents:
diff changeset
538
anatofuz
parents:
diff changeset
539 template <class _Tp>
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
540 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
150
anatofuz
parents:
diff changeset
541 reference_wrapper<_Tp>
anatofuz
parents:
diff changeset
542 ref(reference_wrapper<_Tp> __t) _NOEXCEPT
anatofuz
parents:
diff changeset
543 {
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
544 return _VSTD::ref(__t.get());
150
anatofuz
parents:
diff changeset
545 }
anatofuz
parents:
diff changeset
546
anatofuz
parents:
diff changeset
547 template <class _Tp>
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
548 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
150
anatofuz
parents:
diff changeset
549 reference_wrapper<const _Tp>
anatofuz
parents:
diff changeset
550 cref(const _Tp& __t) _NOEXCEPT
anatofuz
parents:
diff changeset
551 {
anatofuz
parents:
diff changeset
552 return reference_wrapper<const _Tp>(__t);
anatofuz
parents:
diff changeset
553 }
anatofuz
parents:
diff changeset
554
anatofuz
parents:
diff changeset
555 template <class _Tp>
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
556 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
150
anatofuz
parents:
diff changeset
557 reference_wrapper<const _Tp>
anatofuz
parents:
diff changeset
558 cref(reference_wrapper<_Tp> __t) _NOEXCEPT
anatofuz
parents:
diff changeset
559 {
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
560 return _VSTD::cref(__t.get());
150
anatofuz
parents:
diff changeset
561 }
anatofuz
parents:
diff changeset
562
anatofuz
parents:
diff changeset
563 #ifndef _LIBCPP_CXX03_LANG
anatofuz
parents:
diff changeset
564 template <class _Tp> void ref(const _Tp&&) = delete;
anatofuz
parents:
diff changeset
565 template <class _Tp> void cref(const _Tp&&) = delete;
anatofuz
parents:
diff changeset
566 #endif
anatofuz
parents:
diff changeset
567
anatofuz
parents:
diff changeset
568 #if _LIBCPP_STD_VER > 11
anatofuz
parents:
diff changeset
569 template <class _Tp, class, class = void>
anatofuz
parents:
diff changeset
570 struct __is_transparent : false_type {};
anatofuz
parents:
diff changeset
571
anatofuz
parents:
diff changeset
572 template <class _Tp, class _Up>
anatofuz
parents:
diff changeset
573 struct __is_transparent<_Tp, _Up,
anatofuz
parents:
diff changeset
574 typename __void_t<typename _Tp::is_transparent>::type>
anatofuz
parents:
diff changeset
575 : true_type {};
anatofuz
parents:
diff changeset
576 #endif
anatofuz
parents:
diff changeset
577
anatofuz
parents:
diff changeset
578 // allocator_arg_t
anatofuz
parents:
diff changeset
579
anatofuz
parents:
diff changeset
580 struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { explicit allocator_arg_t() = default; };
anatofuz
parents:
diff changeset
581
anatofuz
parents:
diff changeset
582 #if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
anatofuz
parents:
diff changeset
583 extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg;
anatofuz
parents:
diff changeset
584 #else
anatofuz
parents:
diff changeset
585 /* _LIBCPP_INLINE_VAR */ constexpr allocator_arg_t allocator_arg = allocator_arg_t();
anatofuz
parents:
diff changeset
586 #endif
anatofuz
parents:
diff changeset
587
anatofuz
parents:
diff changeset
588 // uses_allocator
anatofuz
parents:
diff changeset
589
anatofuz
parents:
diff changeset
590 template <class _Tp>
anatofuz
parents:
diff changeset
591 struct __has_allocator_type
anatofuz
parents:
diff changeset
592 {
anatofuz
parents:
diff changeset
593 private:
anatofuz
parents:
diff changeset
594 struct __two {char __lx; char __lxx;};
anatofuz
parents:
diff changeset
595 template <class _Up> static __two __test(...);
anatofuz
parents:
diff changeset
596 template <class _Up> static char __test(typename _Up::allocator_type* = 0);
anatofuz
parents:
diff changeset
597 public:
anatofuz
parents:
diff changeset
598 static const bool value = sizeof(__test<_Tp>(0)) == 1;
anatofuz
parents:
diff changeset
599 };
anatofuz
parents:
diff changeset
600
anatofuz
parents:
diff changeset
601 template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value>
anatofuz
parents:
diff changeset
602 struct __uses_allocator
anatofuz
parents:
diff changeset
603 : public integral_constant<bool,
anatofuz
parents:
diff changeset
604 is_convertible<_Alloc, typename _Tp::allocator_type>::value>
anatofuz
parents:
diff changeset
605 {
anatofuz
parents:
diff changeset
606 };
anatofuz
parents:
diff changeset
607
anatofuz
parents:
diff changeset
608 template <class _Tp, class _Alloc>
anatofuz
parents:
diff changeset
609 struct __uses_allocator<_Tp, _Alloc, false>
anatofuz
parents:
diff changeset
610 : public false_type
anatofuz
parents:
diff changeset
611 {
anatofuz
parents:
diff changeset
612 };
anatofuz
parents:
diff changeset
613
anatofuz
parents:
diff changeset
614 template <class _Tp, class _Alloc>
anatofuz
parents:
diff changeset
615 struct _LIBCPP_TEMPLATE_VIS uses_allocator
anatofuz
parents:
diff changeset
616 : public __uses_allocator<_Tp, _Alloc>
anatofuz
parents:
diff changeset
617 {
anatofuz
parents:
diff changeset
618 };
anatofuz
parents:
diff changeset
619
anatofuz
parents:
diff changeset
620 #if _LIBCPP_STD_VER > 14
anatofuz
parents:
diff changeset
621 template <class _Tp, class _Alloc>
anatofuz
parents:
diff changeset
622 _LIBCPP_INLINE_VAR constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value;
anatofuz
parents:
diff changeset
623 #endif
anatofuz
parents:
diff changeset
624
anatofuz
parents:
diff changeset
625 #ifndef _LIBCPP_CXX03_LANG
anatofuz
parents:
diff changeset
626
anatofuz
parents:
diff changeset
627 // allocator construction
anatofuz
parents:
diff changeset
628
anatofuz
parents:
diff changeset
629 template <class _Tp, class _Alloc, class ..._Args>
anatofuz
parents:
diff changeset
630 struct __uses_alloc_ctor_imp
anatofuz
parents:
diff changeset
631 {
anatofuz
parents:
diff changeset
632 typedef _LIBCPP_NODEBUG_TYPE typename __uncvref<_Alloc>::type _RawAlloc;
anatofuz
parents:
diff changeset
633 static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
anatofuz
parents:
diff changeset
634 static const bool __ic =
anatofuz
parents:
diff changeset
635 is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
anatofuz
parents:
diff changeset
636 static const int value = __ua ? 2 - __ic : 0;
anatofuz
parents:
diff changeset
637 };
anatofuz
parents:
diff changeset
638
anatofuz
parents:
diff changeset
639 template <class _Tp, class _Alloc, class ..._Args>
anatofuz
parents:
diff changeset
640 struct __uses_alloc_ctor
anatofuz
parents:
diff changeset
641 : integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value>
anatofuz
parents:
diff changeset
642 {};
anatofuz
parents:
diff changeset
643
anatofuz
parents:
diff changeset
644 template <class _Tp, class _Allocator, class... _Args>
anatofuz
parents:
diff changeset
645 inline _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
646 void __user_alloc_construct_impl (integral_constant<int, 0>, _Tp *__storage, const _Allocator &, _Args &&... __args )
anatofuz
parents:
diff changeset
647 {
anatofuz
parents:
diff changeset
648 new (__storage) _Tp (_VSTD::forward<_Args>(__args)...);
anatofuz
parents:
diff changeset
649 }
anatofuz
parents:
diff changeset
650
anatofuz
parents:
diff changeset
651 // FIXME: This should have a version which takes a non-const alloc.
anatofuz
parents:
diff changeset
652 template <class _Tp, class _Allocator, class... _Args>
anatofuz
parents:
diff changeset
653 inline _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
654 void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
anatofuz
parents:
diff changeset
655 {
anatofuz
parents:
diff changeset
656 new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...);
anatofuz
parents:
diff changeset
657 }
anatofuz
parents:
diff changeset
658
anatofuz
parents:
diff changeset
659 // FIXME: This should have a version which takes a non-const alloc.
anatofuz
parents:
diff changeset
660 template <class _Tp, class _Allocator, class... _Args>
anatofuz
parents:
diff changeset
661 inline _LIBCPP_INLINE_VISIBILITY
anatofuz
parents:
diff changeset
662 void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
anatofuz
parents:
diff changeset
663 {
anatofuz
parents:
diff changeset
664 new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a);
anatofuz
parents:
diff changeset
665 }
anatofuz
parents:
diff changeset
666
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
667 #endif // _LIBCPP_CXX03_LANG
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
668
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
669 #if _LIBCPP_STD_VER > 14
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
670
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
671 template <class _Fn, class ..._Args>
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
672 _LIBCPP_CONSTEXPR_AFTER_CXX17 invoke_result_t<_Fn, _Args...>
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
673 invoke(_Fn&& __f, _Args&&... __args)
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
674 noexcept(is_nothrow_invocable_v<_Fn, _Args...>)
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
675 {
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
676 return _VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
677 }
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
678
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
679 #endif // _LIBCPP_STD_VER > 14
150
anatofuz
parents:
diff changeset
680
anatofuz
parents:
diff changeset
681 _LIBCPP_END_NAMESPACE_STD
anatofuz
parents:
diff changeset
682
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
683 #endif // _LIBCPP_FUNCTIONAL_BASE