blob: 977ada67f335b267ce841377de54de9d4add0670 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:161// -*- C++ -*-
2//===------------------------ functional ----------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:014// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:165//
Howard Hinnantb64f8b02010-11-16 22:09:026// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:168//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_FUNCTIONAL
12#define _LIBCPP_FUNCTIONAL
13
14/*
15 functional synopsis
16
17namespace std
18{
19
20template <class Arg, class Result>
21struct unary_function
22{
23 typedef Arg argument_type;
24 typedef Result result_type;
25};
26
27template <class Arg1, class Arg2, class Result>
28struct binary_function
29{
30 typedef Arg1 first_argument_type;
31 typedef Arg2 second_argument_type;
32 typedef Result result_type;
33};
34
Howard Hinnant72552802010-08-20 19:36:4635template <class T>
Howard Hinnantbc8d3f92010-05-11 19:42:1636class reference_wrapper
37 : public unary_function<T1, R> // if wrapping a unary functor
38 : public binary_function<T1, T2, R> // if wraping a binary functor
39{
40public:
41 // types
42 typedef T type;
43 typedef see below result_type; // Not always defined
44
45 // construct/copy/destroy
Howard Hinnant603d2c02011-05-28 17:59:4846 reference_wrapper(T&) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:1647 reference_wrapper(T&&) = delete; // do not bind to temps
Howard Hinnant603d2c02011-05-28 17:59:4848 reference_wrapper(const reference_wrapper<T>& x) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:1649
50 // assignment
Howard Hinnant603d2c02011-05-28 17:59:4851 reference_wrapper& operator=(const reference_wrapper<T>& x) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:1652
53 // access
Howard Hinnant603d2c02011-05-28 17:59:4854 operator T& () const noexcept;
55 T& get() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:1656
57 // invoke
58 template <class... ArgTypes>
Howard Hinnant23e470c2013-09-21 17:58:5859 typename result_of<T&(ArgTypes&&...)>::type
Howard Hinnantbc8d3f92010-05-11 19:42:1660 operator() (ArgTypes&&...) const;
61};
62
Howard Hinnant603d2c02011-05-28 17:59:4863template <class T> reference_wrapper<T> ref(T& t) noexcept;
Howard Hinnant72552802010-08-20 19:36:4664template <class T> void ref(const T&& t) = delete;
Howard Hinnant603d2c02011-05-28 17:59:4865template <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:1666
Howard Hinnant603d2c02011-05-28 17:59:4867template <class T> reference_wrapper<const T> cref(const T& t) noexcept;
Howard Hinnant72552802010-08-20 19:36:4668template <class T> void cref(const T&& t) = delete;
Howard Hinnant603d2c02011-05-28 17:59:4869template <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:1670
Marshall Clowff464092013-07-29 14:21:5371template <class T> // <class T=void> in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:1672struct plus : binary_function<T, T, T>
73{
74 T operator()(const T& x, const T& y) const;
75};
76
Marshall Clowff464092013-07-29 14:21:5377template <class T> // <class T=void> in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:1678struct minus : binary_function<T, T, T>
79{
80 T operator()(const T& x, const T& y) const;
81};
82
Marshall Clowff464092013-07-29 14:21:5383template <class T> // <class T=void> in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:1684struct multiplies : binary_function<T, T, T>
85{
86 T operator()(const T& x, const T& y) const;
87};
88
Marshall Clowff464092013-07-29 14:21:5389template <class T> // <class T=void> in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:1690struct divides : binary_function<T, T, T>
91{
92 T operator()(const T& x, const T& y) const;
93};
94
Marshall Clowff464092013-07-29 14:21:5395template <class T> // <class T=void> in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:1696struct modulus : binary_function<T, T, T>
97{
98 T operator()(const T& x, const T& y) const;
99};
100
Marshall Clowff464092013-07-29 14:21:53101template <class T> // <class T=void> in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16102struct negate : unary_function<T, T>
103{
104 T operator()(const T& x) const;
105};
106
Marshall Clowff464092013-07-29 14:21:53107template <class T> // <class T=void> in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16108struct equal_to : binary_function<T, T, bool>
109{
110 bool operator()(const T& x, const T& y) const;
111};
112
Marshall Clowff464092013-07-29 14:21:53113template <class T> // <class T=void> in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16114struct not_equal_to : binary_function<T, T, bool>
115{
116 bool operator()(const T& x, const T& y) const;
117};
118
Marshall Clowff464092013-07-29 14:21:53119template <class T> // <class T=void> in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16120struct greater : binary_function<T, T, bool>
121{
122 bool operator()(const T& x, const T& y) const;
123};
124
Marshall Clowff464092013-07-29 14:21:53125template <class T> // <class T=void> in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16126struct less : binary_function<T, T, bool>
127{
128 bool operator()(const T& x, const T& y) const;
129};
130
Marshall Clowff464092013-07-29 14:21:53131template <class T> // <class T=void> in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16132struct greater_equal : binary_function<T, T, bool>
133{
134 bool operator()(const T& x, const T& y) const;
135};
136
Marshall Clowff464092013-07-29 14:21:53137template <class T> // <class T=void> in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16138struct less_equal : binary_function<T, T, bool>
139{
140 bool operator()(const T& x, const T& y) const;
141};
142
Marshall Clowff464092013-07-29 14:21:53143template <class T> // <class T=void> in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16144struct logical_and : binary_function<T, T, bool>
145{
146 bool operator()(const T& x, const T& y) const;
147};
148
Marshall Clowff464092013-07-29 14:21:53149template <class T> // <class T=void> in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16150struct logical_or : binary_function<T, T, bool>
151{
152 bool operator()(const T& x, const T& y) const;
153};
154
Marshall Clowff464092013-07-29 14:21:53155template <class T> // <class T=void> in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16156struct logical_not : unary_function<T, bool>
157{
158 bool operator()(const T& x) const;
159};
160
Marshall Clowff464092013-07-29 14:21:53161template <class T> // <class T=void> in C++14
162struct bit_and : unary_function<T, bool>
163{
164 bool operator()(const T& x, const T& y) const;
165};
166
167template <class T> // <class T=void> in C++14
168struct bit_or : unary_function<T, bool>
169{
170 bool operator()(const T& x, const T& y) const;
171};
172
173template <class T> // <class T=void> in C++14
174struct bit_xor : unary_function<T, bool>
175{
176 bool operator()(const T& x, const T& y) const;
177};
178
179template <class T=void> // C++14
180struct bit_xor : unary_function<T, bool>
181{
182 bool operator()(const T& x) const;
183};
184
Howard Hinnantbc8d3f92010-05-11 19:42:16185template <class Predicate>
186class unary_negate
187 : public unary_function<typename Predicate::argument_type, bool>
188{
189public:
190 explicit unary_negate(const Predicate& pred);
191 bool operator()(const typename Predicate::argument_type& x) const;
192};
193
194template <class Predicate> unary_negate<Predicate> not1(const Predicate& pred);
195
196template <class Predicate>
197class binary_negate
198 : public binary_function<typename Predicate::first_argument_type,
199 typename Predicate::second_argument_type,
200 bool>
201{
202public:
203 explicit binary_negate(const Predicate& pred);
204 bool operator()(const typename Predicate::first_argument_type& x,
205 const typename Predicate::second_argument_type& y) const;
206};
207
208template <class Predicate> binary_negate<Predicate> not2(const Predicate& pred);
209
Eric Fiselierc2308222016-06-02 01:25:41210template <class F> unspecified not_fn(F&& f); // C++17
211
Howard Hinnantbc8d3f92010-05-11 19:42:16212template<class T> struct is_bind_expression;
213template<class T> struct is_placeholder;
214
Marshall Clow2fffe3a2016-09-22 00:23:15215 // See C++14 20.9.9, Function object binders
216template <class T> constexpr bool is_bind_expression_v
217 = is_bind_expression<T>::value; // C++17
218template <class T> constexpr int is_placeholder_v
219 = is_placeholder<T>::value; // C++17
220
221
Howard Hinnant324bb032010-08-22 00:02:43222template<class Fn, class... BoundArgs>
Howard Hinnant72552802010-08-20 19:36:46223 unspecified bind(Fn&&, BoundArgs&&...);
Howard Hinnant324bb032010-08-22 00:02:43224template<class R, class Fn, class... BoundArgs>
Howard Hinnant72552802010-08-20 19:36:46225 unspecified bind(Fn&&, BoundArgs&&...);
Howard Hinnantbc8d3f92010-05-11 19:42:16226
Howard Hinnant324bb032010-08-22 00:02:43227namespace placeholders {
228 // M is the implementation-defined number of placeholders
Howard Hinnantbc8d3f92010-05-11 19:42:16229 extern unspecified _1;
230 extern unspecified _2;
Howard Hinnant324bb032010-08-22 00:02:43231 .
232 .
233 .
Howard Hinnant99968442011-11-29 18:15:50234 extern unspecified _Mp;
Howard Hinnantbc8d3f92010-05-11 19:42:16235}
236
237template <class Operation>
238class binder1st
239 : public unary_function<typename Operation::second_argument_type,
240 typename Operation::result_type>
241{
242protected:
243 Operation op;
244 typename Operation::first_argument_type value;
245public:
246 binder1st(const Operation& x, const typename Operation::first_argument_type y);
247 typename Operation::result_type operator()( typename Operation::second_argument_type& x) const;
248 typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const;
249};
250
251template <class Operation, class T>
252binder1st<Operation> bind1st(const Operation& op, const T& x);
253
254template <class Operation>
255class binder2nd
256 : public unary_function<typename Operation::first_argument_type,
257 typename Operation::result_type>
258{
259protected:
260 Operation op;
261 typename Operation::second_argument_type value;
262public:
263 binder2nd(const Operation& x, const typename Operation::second_argument_type y);
264 typename Operation::result_type operator()( typename Operation::first_argument_type& x) const;
265 typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const;
266};
267
268template <class Operation, class T>
269binder2nd<Operation> bind2nd(const Operation& op, const T& x);
270
271template <class Arg, class Result>
272class pointer_to_unary_function : public unary_function<Arg, Result>
273{
274public:
275 explicit pointer_to_unary_function(Result (*f)(Arg));
276 Result operator()(Arg x) const;
277};
278
279template <class Arg, class Result>
280pointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg));
281
282template <class Arg1, class Arg2, class Result>
283class pointer_to_binary_function : public binary_function<Arg1, Arg2, Result>
284{
285public:
286 explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2));
287 Result operator()(Arg1 x, Arg2 y) const;
288};
289
290template <class Arg1, class Arg2, class Result>
291pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2));
292
293template<class S, class T>
294class mem_fun_t : public unary_function<T*, S>
295{
296public:
297 explicit mem_fun_t(S (T::*p)());
298 S operator()(T* p) const;
299};
300
301template<class S, class T, class A>
302class mem_fun1_t : public binary_function<T*, A, S>
303{
304public:
305 explicit mem_fun1_t(S (T::*p)(A));
306 S operator()(T* p, A x) const;
307};
308
309template<class S, class T> mem_fun_t<S,T> mem_fun(S (T::*f)());
310template<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A));
311
312template<class S, class T>
313class mem_fun_ref_t : public unary_function<T, S>
314{
315public:
316 explicit mem_fun_ref_t(S (T::*p)());
317 S operator()(T& p) const;
318};
319
320template<class S, class T, class A>
321class mem_fun1_ref_t : public binary_function<T, A, S>
322{
323public:
324 explicit mem_fun1_ref_t(S (T::*p)(A));
325 S operator()(T& p, A x) const;
326};
327
328template<class S, class T> mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)());
329template<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A));
330
331template <class S, class T>
332class const_mem_fun_t : public unary_function<const T*, S>
333{
334public:
335 explicit const_mem_fun_t(S (T::*p)() const);
336 S operator()(const T* p) const;
337};
338
339template <class S, class T, class A>
340class const_mem_fun1_t : public binary_function<const T*, A, S>
341{
342public:
343 explicit const_mem_fun1_t(S (T::*p)(A) const);
344 S operator()(const T* p, A x) const;
345};
346
347template <class S, class T> const_mem_fun_t<S,T> mem_fun(S (T::*f)() const);
348template <class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const);
349
350template <class S, class T>
351class const_mem_fun_ref_t : public unary_function<T, S>
352{
353public:
354 explicit const_mem_fun_ref_t(S (T::*p)() const);
355 S operator()(const T& p) const;
356};
357
358template <class S, class T, class A>
359class const_mem_fun1_ref_t : public binary_function<T, A, S>
360{
361public:
362 explicit const_mem_fun1_ref_t(S (T::*p)(A) const);
363 S operator()(const T& p, A x) const;
364};
365
366template <class S, class T> const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const);
367template <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const);
368
Howard Hinnant72552802010-08-20 19:36:46369template<class R, class T> unspecified mem_fn(R T::*);
Howard Hinnant72552802010-08-20 19:36:46370
Howard Hinnantbc8d3f92010-05-11 19:42:16371class bad_function_call
372 : public exception
373{
374};
375
Howard Hinnant72552802010-08-20 19:36:46376template<class> class function; // undefined
Howard Hinnantbc8d3f92010-05-11 19:42:16377
Howard Hinnant72552802010-08-20 19:36:46378template<class R, class... ArgTypes>
Howard Hinnantbc8d3f92010-05-11 19:42:16379class function<R(ArgTypes...)>
380 : public unary_function<T1, R> // iff sizeof...(ArgTypes) == 1 and
381 // ArgTypes contains T1
382 : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and
383 // ArgTypes contains T1 and T2
384{
385public:
386 typedef R result_type;
387
Howard Hinnant72552802010-08-20 19:36:46388 // construct/copy/destroy:
Howard Hinnant603d2c02011-05-28 17:59:48389 function() noexcept;
390 function(nullptr_t) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16391 function(const function&);
Howard Hinnant603d2c02011-05-28 17:59:48392 function(function&&) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16393 template<class F>
Howard Hinnantbc8d3f92010-05-11 19:42:16394 function(F);
Howard Hinnantbc8d3f92010-05-11 19:42:16395 template<Allocator Alloc>
Marshall Clowe29fb4c2016-10-13 21:06:03396 function(allocator_arg_t, const Alloc&) noexcept; // removed in C++17
Howard Hinnantbc8d3f92010-05-11 19:42:16397 template<Allocator Alloc>
Marshall Clowe29fb4c2016-10-13 21:06:03398 function(allocator_arg_t, const Alloc&, nullptr_t) noexcept; // removed in C++17
Howard Hinnantbc8d3f92010-05-11 19:42:16399 template<Allocator Alloc>
Marshall Clowe29fb4c2016-10-13 21:06:03400 function(allocator_arg_t, const Alloc&, const function&); // removed in C++17
Howard Hinnantbc8d3f92010-05-11 19:42:16401 template<Allocator Alloc>
Marshall Clowe29fb4c2016-10-13 21:06:03402 function(allocator_arg_t, const Alloc&, function&&); // removed in C++17
Howard Hinnantbc8d3f92010-05-11 19:42:16403 template<class F, Allocator Alloc>
Marshall Clowe29fb4c2016-10-13 21:06:03404 function(allocator_arg_t, const Alloc&, F); // removed in C++17
Howard Hinnantbc8d3f92010-05-11 19:42:16405
406 function& operator=(const function&);
Howard Hinnant603d2c02011-05-28 17:59:48407 function& operator=(function&&) noexcept;
Howard Hinnantad1a5cc2011-05-29 13:53:56408 function& operator=(nullptr_t) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16409 template<class F>
Howard Hinnant72552802010-08-20 19:36:46410 function& operator=(F&&);
Howard Hinnantbc8d3f92010-05-11 19:42:16411 template<class F>
Howard Hinnant603d2c02011-05-28 17:59:48412 function& operator=(reference_wrapper<F>) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16413
414 ~function();
415
Howard Hinnant72552802010-08-20 19:36:46416 // function modifiers:
Howard Hinnant603d2c02011-05-28 17:59:48417 void swap(function&) noexcept;
Howard Hinnant72552802010-08-20 19:36:46418 template<class F, class Alloc>
Marshall Clow73de8802016-01-25 17:29:55419 void assign(F&&, const Alloc&); // Removed in C++17
Howard Hinnantbc8d3f92010-05-11 19:42:16420
Howard Hinnant72552802010-08-20 19:36:46421 // function capacity:
Howard Hinnant603d2c02011-05-28 17:59:48422 explicit operator bool() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16423
Howard Hinnant72552802010-08-20 19:36:46424 // function invocation:
Howard Hinnantbc8d3f92010-05-11 19:42:16425 R operator()(ArgTypes...) const;
426
Howard Hinnant72552802010-08-20 19:36:46427 // function target access:
Howard Hinnant603d2c02011-05-28 17:59:48428 const std::type_info& target_type() const noexcept;
429 template <typename T> T* target() noexcept;
430 template <typename T> const T* target() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16431};
432
Howard Hinnant324bb032010-08-22 00:02:43433// Null pointer comparisons:
434template <class R, class ... ArgTypes>
Howard Hinnant603d2c02011-05-28 17:59:48435 bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16436
Howard Hinnant324bb032010-08-22 00:02:43437template <class R, class ... ArgTypes>
Howard Hinnant603d2c02011-05-28 17:59:48438 bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16439
Howard Hinnant324bb032010-08-22 00:02:43440template <class R, class ... ArgTypes>
Howard Hinnant603d2c02011-05-28 17:59:48441 bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16442
Howard Hinnant324bb032010-08-22 00:02:43443template <class R, class ... ArgTypes>
Howard Hinnant603d2c02011-05-28 17:59:48444 bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16445
Howard Hinnant324bb032010-08-22 00:02:43446// specialized algorithms:
447template <class R, class ... ArgTypes>
Howard Hinnant603d2c02011-05-28 17:59:48448 void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16449
450template <class T> struct hash;
451
452template <> struct hash<bool>;
453template <> struct hash<char>;
454template <> struct hash<signed char>;
455template <> struct hash<unsigned char>;
456template <> struct hash<char16_t>;
457template <> struct hash<char32_t>;
458template <> struct hash<wchar_t>;
459template <> struct hash<short>;
460template <> struct hash<unsigned short>;
461template <> struct hash<int>;
462template <> struct hash<unsigned int>;
463template <> struct hash<long>;
464template <> struct hash<long long>;
465template <> struct hash<unsigned long>;
466template <> struct hash<unsigned long long>;
467
468template <> struct hash<float>;
469template <> struct hash<double>;
470template <> struct hash<long double>;
471
472template<class T> struct hash<T*>;
Marshall Clow570f32c2017-03-23 06:20:18473template <> struct hash<nullptr_t>; // C++17
Howard Hinnantbc8d3f92010-05-11 19:42:16474
475} // std
476
477POLICY: For non-variadic implementations, the number of arguments is limited
478 to 3. It is hoped that the need for non-variadic implementations
479 will be minimal.
480
481*/
482
483#include <__config>
484#include <type_traits>
485#include <typeinfo>
486#include <exception>
487#include <memory>
488#include <tuple>
Eric Fiselier952eaec2017-01-21 00:02:12489#include <utility>
Howard Hinnantbc8d3f92010-05-11 19:42:16490
491#include <__functional_base>
492
Howard Hinnant08e17472011-10-17 20:05:10493#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16494#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10495#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16496
497_LIBCPP_BEGIN_NAMESPACE_STD
498
Marshall Clowff464092013-07-29 14:21:53499#if _LIBCPP_STD_VER > 11
500template <class _Tp = void>
501#else
Howard Hinnantbc8d3f92010-05-11 19:42:16502template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53503#endif
Eric Fiselierc3589a82017-01-04 23:56:00504struct _LIBCPP_TEMPLATE_VIS plus : binary_function<_Tp, _Tp, _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16505{
Marshall Clow9738caf2013-09-28 19:06:12506 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
507 _Tp operator()(const _Tp& __x, const _Tp& __y) const
Howard Hinnantbc8d3f92010-05-11 19:42:16508 {return __x + __y;}
509};
510
Marshall Clowff464092013-07-29 14:21:53511#if _LIBCPP_STD_VER > 11
512template <>
Eric Fiselierc3589a82017-01-04 23:56:00513struct _LIBCPP_TEMPLATE_VIS plus<void>
Marshall Clowff464092013-07-29 14:21:53514{
515 template <class _T1, class _T2>
Marshall Clow9738caf2013-09-28 19:06:12516 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
517 auto operator()(_T1&& __t, _T2&& __u) const
Marshall Clow59ac38c2015-02-25 12:20:52518 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
519 -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
520 { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
Marshall Clow4a0a9812013-08-13 01:11:06521 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53522};
523#endif
524
525
526#if _LIBCPP_STD_VER > 11
527template <class _Tp = void>
528#else
Howard Hinnantbc8d3f92010-05-11 19:42:16529template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53530#endif
Eric Fiselierc3589a82017-01-04 23:56:00531struct _LIBCPP_TEMPLATE_VIS minus : binary_function<_Tp, _Tp, _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16532{
Marshall Clow9738caf2013-09-28 19:06:12533 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
534 _Tp operator()(const _Tp& __x, const _Tp& __y) const
Howard Hinnantbc8d3f92010-05-11 19:42:16535 {return __x - __y;}
536};
537
Marshall Clowff464092013-07-29 14:21:53538#if _LIBCPP_STD_VER > 11
539template <>
Eric Fiselierc3589a82017-01-04 23:56:00540struct _LIBCPP_TEMPLATE_VIS minus<void>
Marshall Clowff464092013-07-29 14:21:53541{
542 template <class _T1, class _T2>
Marshall Clow9738caf2013-09-28 19:06:12543 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
544 auto operator()(_T1&& __t, _T2&& __u) const
Marshall Clow59ac38c2015-02-25 12:20:52545 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
546 -> decltype (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
547 { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
Marshall Clow4a0a9812013-08-13 01:11:06548 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53549};
550#endif
551
552
553#if _LIBCPP_STD_VER > 11
554template <class _Tp = void>
555#else
Howard Hinnantbc8d3f92010-05-11 19:42:16556template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53557#endif
Eric Fiselierc3589a82017-01-04 23:56:00558struct _LIBCPP_TEMPLATE_VIS multiplies : binary_function<_Tp, _Tp, _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16559{
Marshall Clow9738caf2013-09-28 19:06:12560 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
561 _Tp operator()(const _Tp& __x, const _Tp& __y) const
Howard Hinnantbc8d3f92010-05-11 19:42:16562 {return __x * __y;}
563};
564
Marshall Clowff464092013-07-29 14:21:53565#if _LIBCPP_STD_VER > 11
566template <>
Eric Fiselierc3589a82017-01-04 23:56:00567struct _LIBCPP_TEMPLATE_VIS multiplies<void>
Marshall Clowff464092013-07-29 14:21:53568{
569 template <class _T1, class _T2>
Marshall Clow9738caf2013-09-28 19:06:12570 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
571 auto operator()(_T1&& __t, _T2&& __u) const
Marshall Clow59ac38c2015-02-25 12:20:52572 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
573 -> decltype (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
574 { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
Marshall Clow4a0a9812013-08-13 01:11:06575 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53576};
577#endif
578
579
580#if _LIBCPP_STD_VER > 11
581template <class _Tp = void>
582#else
Howard Hinnantbc8d3f92010-05-11 19:42:16583template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53584#endif
Eric Fiselierc3589a82017-01-04 23:56:00585struct _LIBCPP_TEMPLATE_VIS divides : binary_function<_Tp, _Tp, _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16586{
Marshall Clow9738caf2013-09-28 19:06:12587 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
588 _Tp operator()(const _Tp& __x, const _Tp& __y) const
Howard Hinnantbc8d3f92010-05-11 19:42:16589 {return __x / __y;}
590};
591
Marshall Clowff464092013-07-29 14:21:53592#if _LIBCPP_STD_VER > 11
593template <>
Eric Fiselierc3589a82017-01-04 23:56:00594struct _LIBCPP_TEMPLATE_VIS divides<void>
Marshall Clowff464092013-07-29 14:21:53595{
596 template <class _T1, class _T2>
Marshall Clow9738caf2013-09-28 19:06:12597 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
598 auto operator()(_T1&& __t, _T2&& __u) const
Marshall Clow59ac38c2015-02-25 12:20:52599 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
600 -> decltype (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
601 { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
Marshall Clow4a0a9812013-08-13 01:11:06602 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53603};
604#endif
605
606
607#if _LIBCPP_STD_VER > 11
608template <class _Tp = void>
609#else
Howard Hinnantbc8d3f92010-05-11 19:42:16610template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53611#endif
Eric Fiselierc3589a82017-01-04 23:56:00612struct _LIBCPP_TEMPLATE_VIS modulus : binary_function<_Tp, _Tp, _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16613{
Marshall Clow9738caf2013-09-28 19:06:12614 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
615 _Tp operator()(const _Tp& __x, const _Tp& __y) const
Howard Hinnantbc8d3f92010-05-11 19:42:16616 {return __x % __y;}
617};
618
Marshall Clowff464092013-07-29 14:21:53619#if _LIBCPP_STD_VER > 11
620template <>
Eric Fiselierc3589a82017-01-04 23:56:00621struct _LIBCPP_TEMPLATE_VIS modulus<void>
Marshall Clowff464092013-07-29 14:21:53622{
623 template <class _T1, class _T2>
Marshall Clow9738caf2013-09-28 19:06:12624 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
625 auto operator()(_T1&& __t, _T2&& __u) const
Marshall Clow59ac38c2015-02-25 12:20:52626 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
627 -> decltype (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
628 { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
Marshall Clow4a0a9812013-08-13 01:11:06629 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53630};
631#endif
632
633
634#if _LIBCPP_STD_VER > 11
635template <class _Tp = void>
636#else
Howard Hinnantbc8d3f92010-05-11 19:42:16637template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53638#endif
Eric Fiselierc3589a82017-01-04 23:56:00639struct _LIBCPP_TEMPLATE_VIS negate : unary_function<_Tp, _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16640{
Marshall Clow9738caf2013-09-28 19:06:12641 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
642 _Tp operator()(const _Tp& __x) const
Howard Hinnantbc8d3f92010-05-11 19:42:16643 {return -__x;}
644};
645
Marshall Clowff464092013-07-29 14:21:53646#if _LIBCPP_STD_VER > 11
647template <>
Eric Fiselierc3589a82017-01-04 23:56:00648struct _LIBCPP_TEMPLATE_VIS negate<void>
Marshall Clowff464092013-07-29 14:21:53649{
650 template <class _Tp>
Marshall Clow9738caf2013-09-28 19:06:12651 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
652 auto operator()(_Tp&& __x) const
Marshall Clow59ac38c2015-02-25 12:20:52653 _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x)))
654 -> decltype (- _VSTD::forward<_Tp>(__x))
655 { return - _VSTD::forward<_Tp>(__x); }
Marshall Clow4a0a9812013-08-13 01:11:06656 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53657};
658#endif
659
660
661#if _LIBCPP_STD_VER > 11
662template <class _Tp = void>
663#else
Howard Hinnantbc8d3f92010-05-11 19:42:16664template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53665#endif
Eric Fiselierc3589a82017-01-04 23:56:00666struct _LIBCPP_TEMPLATE_VIS equal_to : binary_function<_Tp, _Tp, bool>
Howard Hinnantbc8d3f92010-05-11 19:42:16667{
Marshall Clow9738caf2013-09-28 19:06:12668 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
669 bool operator()(const _Tp& __x, const _Tp& __y) const
Howard Hinnantbc8d3f92010-05-11 19:42:16670 {return __x == __y;}
671};
672
Marshall Clowff464092013-07-29 14:21:53673#if _LIBCPP_STD_VER > 11
674template <>
Eric Fiselierc3589a82017-01-04 23:56:00675struct _LIBCPP_TEMPLATE_VIS equal_to<void>
Marshall Clowff464092013-07-29 14:21:53676{
Marshall Clow9738caf2013-09-28 19:06:12677 template <class _T1, class _T2>
678 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
Marshall Clowff464092013-07-29 14:21:53679 auto operator()(_T1&& __t, _T2&& __u) const
Marshall Clow59ac38c2015-02-25 12:20:52680 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
681 -> decltype (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
682 { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
Marshall Clow4a0a9812013-08-13 01:11:06683 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53684};
685#endif
686
687
688#if _LIBCPP_STD_VER > 11
689template <class _Tp = void>
690#else
Howard Hinnantbc8d3f92010-05-11 19:42:16691template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53692#endif
Eric Fiselierc3589a82017-01-04 23:56:00693struct _LIBCPP_TEMPLATE_VIS not_equal_to : binary_function<_Tp, _Tp, bool>
Howard Hinnantbc8d3f92010-05-11 19:42:16694{
Marshall Clow9738caf2013-09-28 19:06:12695 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
696 bool operator()(const _Tp& __x, const _Tp& __y) const
Howard Hinnantbc8d3f92010-05-11 19:42:16697 {return __x != __y;}
698};
699
Marshall Clowff464092013-07-29 14:21:53700#if _LIBCPP_STD_VER > 11
701template <>
Eric Fiselierc3589a82017-01-04 23:56:00702struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
Marshall Clowff464092013-07-29 14:21:53703{
Marshall Clow9738caf2013-09-28 19:06:12704 template <class _T1, class _T2>
705 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
Marshall Clowff464092013-07-29 14:21:53706 auto operator()(_T1&& __t, _T2&& __u) const
Marshall Clow59ac38c2015-02-25 12:20:52707 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
708 -> decltype (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
709 { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
Marshall Clow4a0a9812013-08-13 01:11:06710 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53711};
712#endif
713
714
715#if _LIBCPP_STD_VER > 11
716template <class _Tp = void>
717#else
Howard Hinnantbc8d3f92010-05-11 19:42:16718template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53719#endif
Eric Fiselierc3589a82017-01-04 23:56:00720struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
Howard Hinnantbc8d3f92010-05-11 19:42:16721{
Marshall Clow9738caf2013-09-28 19:06:12722 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
723 bool operator()(const _Tp& __x, const _Tp& __y) const
Howard Hinnantbc8d3f92010-05-11 19:42:16724 {return __x > __y;}
725};
726
Marshall Clowff464092013-07-29 14:21:53727#if _LIBCPP_STD_VER > 11
728template <>
Eric Fiselierc3589a82017-01-04 23:56:00729struct _LIBCPP_TEMPLATE_VIS greater<void>
Marshall Clowff464092013-07-29 14:21:53730{
Marshall Clow9738caf2013-09-28 19:06:12731 template <class _T1, class _T2>
732 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
Marshall Clowff464092013-07-29 14:21:53733 auto operator()(_T1&& __t, _T2&& __u) const
Marshall Clow59ac38c2015-02-25 12:20:52734 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
735 -> decltype (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
736 { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
Marshall Clow4a0a9812013-08-13 01:11:06737 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53738};
739#endif
740
741
Howard Hinnant3fadda32012-02-21 21:02:58742// less in <__functional_base>
Howard Hinnantbc8d3f92010-05-11 19:42:16743
Marshall Clowff464092013-07-29 14:21:53744#if _LIBCPP_STD_VER > 11
745template <class _Tp = void>
746#else
Howard Hinnantbc8d3f92010-05-11 19:42:16747template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53748#endif
Eric Fiselierc3589a82017-01-04 23:56:00749struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
Howard Hinnantbc8d3f92010-05-11 19:42:16750{
Marshall Clow9738caf2013-09-28 19:06:12751 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
752 bool operator()(const _Tp& __x, const _Tp& __y) const
Howard Hinnantbc8d3f92010-05-11 19:42:16753 {return __x >= __y;}
754};
755
Marshall Clowff464092013-07-29 14:21:53756#if _LIBCPP_STD_VER > 11
757template <>
Eric Fiselierc3589a82017-01-04 23:56:00758struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
Marshall Clowff464092013-07-29 14:21:53759{
Marshall Clow9738caf2013-09-28 19:06:12760 template <class _T1, class _T2>
761 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
Marshall Clowff464092013-07-29 14:21:53762 auto operator()(_T1&& __t, _T2&& __u) const
Marshall Clow59ac38c2015-02-25 12:20:52763 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
764 -> decltype (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
765 { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
Marshall Clow4a0a9812013-08-13 01:11:06766 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53767};
768#endif
769
770
771#if _LIBCPP_STD_VER > 11
772template <class _Tp = void>
773#else
Howard Hinnantbc8d3f92010-05-11 19:42:16774template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53775#endif
Eric Fiselierc3589a82017-01-04 23:56:00776struct _LIBCPP_TEMPLATE_VIS less_equal : binary_function<_Tp, _Tp, bool>
Howard Hinnantbc8d3f92010-05-11 19:42:16777{
Marshall Clow9738caf2013-09-28 19:06:12778 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
779 bool operator()(const _Tp& __x, const _Tp& __y) const
Howard Hinnantbc8d3f92010-05-11 19:42:16780 {return __x <= __y;}
781};
782
Marshall Clowff464092013-07-29 14:21:53783#if _LIBCPP_STD_VER > 11
784template <>
Eric Fiselierc3589a82017-01-04 23:56:00785struct _LIBCPP_TEMPLATE_VIS less_equal<void>
Marshall Clowff464092013-07-29 14:21:53786{
Marshall Clow9738caf2013-09-28 19:06:12787 template <class _T1, class _T2>
788 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
Marshall Clowff464092013-07-29 14:21:53789 auto operator()(_T1&& __t, _T2&& __u) const
Marshall Clow59ac38c2015-02-25 12:20:52790 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
791 -> decltype (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
792 { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
Marshall Clow4a0a9812013-08-13 01:11:06793 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53794};
795#endif
796
797
798#if _LIBCPP_STD_VER > 11
799template <class _Tp = void>
800#else
Howard Hinnantbc8d3f92010-05-11 19:42:16801template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53802#endif
Eric Fiselierc3589a82017-01-04 23:56:00803struct _LIBCPP_TEMPLATE_VIS logical_and : binary_function<_Tp, _Tp, bool>
Howard Hinnantbc8d3f92010-05-11 19:42:16804{
Marshall Clow9738caf2013-09-28 19:06:12805 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
806 bool operator()(const _Tp& __x, const _Tp& __y) const
Howard Hinnantbc8d3f92010-05-11 19:42:16807 {return __x && __y;}
808};
809
Marshall Clowff464092013-07-29 14:21:53810#if _LIBCPP_STD_VER > 11
811template <>
Eric Fiselierc3589a82017-01-04 23:56:00812struct _LIBCPP_TEMPLATE_VIS logical_and<void>
Marshall Clowff464092013-07-29 14:21:53813{
Marshall Clow9738caf2013-09-28 19:06:12814 template <class _T1, class _T2>
815 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
Marshall Clowff464092013-07-29 14:21:53816 auto operator()(_T1&& __t, _T2&& __u) const
Marshall Clow59ac38c2015-02-25 12:20:52817 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
818 -> decltype (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
819 { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
Marshall Clow4a0a9812013-08-13 01:11:06820 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53821};
822#endif
823
824
825#if _LIBCPP_STD_VER > 11
826template <class _Tp = void>
827#else
Howard Hinnantbc8d3f92010-05-11 19:42:16828template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53829#endif
Eric Fiselierc3589a82017-01-04 23:56:00830struct _LIBCPP_TEMPLATE_VIS logical_or : binary_function<_Tp, _Tp, bool>
Howard Hinnantbc8d3f92010-05-11 19:42:16831{
Marshall Clow9738caf2013-09-28 19:06:12832 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
833 bool operator()(const _Tp& __x, const _Tp& __y) const
Howard Hinnantbc8d3f92010-05-11 19:42:16834 {return __x || __y;}
835};
836
Marshall Clowff464092013-07-29 14:21:53837#if _LIBCPP_STD_VER > 11
838template <>
Eric Fiselierc3589a82017-01-04 23:56:00839struct _LIBCPP_TEMPLATE_VIS logical_or<void>
Marshall Clowff464092013-07-29 14:21:53840{
Marshall Clow9738caf2013-09-28 19:06:12841 template <class _T1, class _T2>
842 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
Marshall Clowff464092013-07-29 14:21:53843 auto operator()(_T1&& __t, _T2&& __u) const
Marshall Clow59ac38c2015-02-25 12:20:52844 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
845 -> decltype (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
846 { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
Marshall Clow4a0a9812013-08-13 01:11:06847 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53848};
849#endif
850
851
852#if _LIBCPP_STD_VER > 11
853template <class _Tp = void>
854#else
Howard Hinnantbc8d3f92010-05-11 19:42:16855template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53856#endif
Eric Fiselierc3589a82017-01-04 23:56:00857struct _LIBCPP_TEMPLATE_VIS logical_not : unary_function<_Tp, bool>
Howard Hinnantbc8d3f92010-05-11 19:42:16858{
Marshall Clow9738caf2013-09-28 19:06:12859 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
860 bool operator()(const _Tp& __x) const
Howard Hinnantbc8d3f92010-05-11 19:42:16861 {return !__x;}
862};
863
Marshall Clowff464092013-07-29 14:21:53864#if _LIBCPP_STD_VER > 11
865template <>
Eric Fiselierc3589a82017-01-04 23:56:00866struct _LIBCPP_TEMPLATE_VIS logical_not<void>
Marshall Clowff464092013-07-29 14:21:53867{
868 template <class _Tp>
Marshall Clow9738caf2013-09-28 19:06:12869 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
870 auto operator()(_Tp&& __x) const
Marshall Clow59ac38c2015-02-25 12:20:52871 _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x)))
872 -> decltype (!_VSTD::forward<_Tp>(__x))
873 { return !_VSTD::forward<_Tp>(__x); }
Marshall Clow4a0a9812013-08-13 01:11:06874 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53875};
876#endif
877
878
879#if _LIBCPP_STD_VER > 11
880template <class _Tp = void>
881#else
Howard Hinnantbc8d3f92010-05-11 19:42:16882template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53883#endif
Eric Fiselierc3589a82017-01-04 23:56:00884struct _LIBCPP_TEMPLATE_VIS bit_and : binary_function<_Tp, _Tp, _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16885{
Marshall Clow9738caf2013-09-28 19:06:12886 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
887 _Tp operator()(const _Tp& __x, const _Tp& __y) const
Howard Hinnantbc8d3f92010-05-11 19:42:16888 {return __x & __y;}
889};
890
Marshall Clowff464092013-07-29 14:21:53891#if _LIBCPP_STD_VER > 11
892template <>
Eric Fiselierc3589a82017-01-04 23:56:00893struct _LIBCPP_TEMPLATE_VIS bit_and<void>
Marshall Clowff464092013-07-29 14:21:53894{
Marshall Clow9738caf2013-09-28 19:06:12895 template <class _T1, class _T2>
896 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
Marshall Clowff464092013-07-29 14:21:53897 auto operator()(_T1&& __t, _T2&& __u) const
Marshall Clow59ac38c2015-02-25 12:20:52898 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
899 -> decltype (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
900 { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
Marshall Clow4a0a9812013-08-13 01:11:06901 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53902};
903#endif
904
905
906#if _LIBCPP_STD_VER > 11
907template <class _Tp = void>
908#else
Howard Hinnantbc8d3f92010-05-11 19:42:16909template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53910#endif
Eric Fiselierc3589a82017-01-04 23:56:00911struct _LIBCPP_TEMPLATE_VIS bit_or : binary_function<_Tp, _Tp, _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16912{
Marshall Clow9738caf2013-09-28 19:06:12913 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
914 _Tp operator()(const _Tp& __x, const _Tp& __y) const
Howard Hinnantbc8d3f92010-05-11 19:42:16915 {return __x | __y;}
916};
917
Marshall Clowff464092013-07-29 14:21:53918#if _LIBCPP_STD_VER > 11
919template <>
Eric Fiselierc3589a82017-01-04 23:56:00920struct _LIBCPP_TEMPLATE_VIS bit_or<void>
Marshall Clowff464092013-07-29 14:21:53921{
Marshall Clow9738caf2013-09-28 19:06:12922 template <class _T1, class _T2>
923 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
Marshall Clowff464092013-07-29 14:21:53924 auto operator()(_T1&& __t, _T2&& __u) const
Marshall Clow59ac38c2015-02-25 12:20:52925 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
926 -> decltype (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
927 { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
Marshall Clow4a0a9812013-08-13 01:11:06928 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53929};
930#endif
931
932
933#if _LIBCPP_STD_VER > 11
934template <class _Tp = void>
935#else
Howard Hinnantbc8d3f92010-05-11 19:42:16936template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53937#endif
Eric Fiselierc3589a82017-01-04 23:56:00938struct _LIBCPP_TEMPLATE_VIS bit_xor : binary_function<_Tp, _Tp, _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:16939{
Marshall Clow9738caf2013-09-28 19:06:12940 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
941 _Tp operator()(const _Tp& __x, const _Tp& __y) const
Howard Hinnantbc8d3f92010-05-11 19:42:16942 {return __x ^ __y;}
943};
944
Marshall Clowff464092013-07-29 14:21:53945#if _LIBCPP_STD_VER > 11
946template <>
Eric Fiselierc3589a82017-01-04 23:56:00947struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
Marshall Clowff464092013-07-29 14:21:53948{
Marshall Clow9738caf2013-09-28 19:06:12949 template <class _T1, class _T2>
950 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
Marshall Clowff464092013-07-29 14:21:53951 auto operator()(_T1&& __t, _T2&& __u) const
Marshall Clow59ac38c2015-02-25 12:20:52952 _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
953 -> decltype (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
954 { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
Marshall Clow4a0a9812013-08-13 01:11:06955 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53956};
957#endif
958
959
960#if _LIBCPP_STD_VER > 11
961template <class _Tp = void>
Eric Fiselierc3589a82017-01-04 23:56:00962struct _LIBCPP_TEMPLATE_VIS bit_not : unary_function<_Tp, _Tp>
Marshall Clowff464092013-07-29 14:21:53963{
Marshall Clow9738caf2013-09-28 19:06:12964 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
965 _Tp operator()(const _Tp& __x) const
Marshall Clowff464092013-07-29 14:21:53966 {return ~__x;}
967};
968
969template <>
Eric Fiselierc3589a82017-01-04 23:56:00970struct _LIBCPP_TEMPLATE_VIS bit_not<void>
Marshall Clowff464092013-07-29 14:21:53971{
972 template <class _Tp>
Marshall Clow9738caf2013-09-28 19:06:12973 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
974 auto operator()(_Tp&& __x) const
Marshall Clow59ac38c2015-02-25 12:20:52975 _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x)))
976 -> decltype (~_VSTD::forward<_Tp>(__x))
977 { return ~_VSTD::forward<_Tp>(__x); }
Marshall Clow4a0a9812013-08-13 01:11:06978 typedef void is_transparent;
Marshall Clowff464092013-07-29 14:21:53979};
980#endif
981
Howard Hinnantbc8d3f92010-05-11 19:42:16982template <class _Predicate>
Eric Fiselierc3589a82017-01-04 23:56:00983class _LIBCPP_TEMPLATE_VIS unary_negate
Howard Hinnantbc8d3f92010-05-11 19:42:16984 : public unary_function<typename _Predicate::argument_type, bool>
985{
986 _Predicate __pred_;
987public:
Marshall Clow9738caf2013-09-28 19:06:12988 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
989 explicit unary_negate(const _Predicate& __pred)
Howard Hinnantbc8d3f92010-05-11 19:42:16990 : __pred_(__pred) {}
Marshall Clow9738caf2013-09-28 19:06:12991 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
992 bool operator()(const typename _Predicate::argument_type& __x) const
Howard Hinnantbc8d3f92010-05-11 19:42:16993 {return !__pred_(__x);}
994};
995
996template <class _Predicate>
Marshall Clow9738caf2013-09-28 19:06:12997inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16998unary_negate<_Predicate>
999not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);}
1000
1001template <class _Predicate>
Eric Fiselierc3589a82017-01-04 23:56:001002class _LIBCPP_TEMPLATE_VIS binary_negate
Howard Hinnantbc8d3f92010-05-11 19:42:161003 : public binary_function<typename _Predicate::first_argument_type,
1004 typename _Predicate::second_argument_type,
1005 bool>
1006{
1007 _Predicate __pred_;
1008public:
Marshall Clow9738caf2013-09-28 19:06:121009 _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11
1010 binary_negate(const _Predicate& __pred) : __pred_(__pred) {}
1011
1012 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
1013 bool operator()(const typename _Predicate::first_argument_type& __x,
Howard Hinnantbc8d3f92010-05-11 19:42:161014 const typename _Predicate::second_argument_type& __y) const
1015 {return !__pred_(__x, __y);}
1016};
1017
1018template <class _Predicate>
Marshall Clow9738caf2013-09-28 19:06:121019inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161020binary_negate<_Predicate>
1021not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}
1022
1023template <class __Operation>
Eric Fiselierc3589a82017-01-04 23:56:001024class _LIBCPP_TEMPLATE_VIS binder1st
Howard Hinnantbc8d3f92010-05-11 19:42:161025 : public unary_function<typename __Operation::second_argument_type,
1026 typename __Operation::result_type>
1027{
1028protected:
1029 __Operation op;
1030 typename __Operation::first_argument_type value;
1031public:
1032 _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x,
1033 const typename __Operation::first_argument_type __y)
1034 : op(__x), value(__y) {}
1035 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1036 (typename __Operation::second_argument_type& __x) const
1037 {return op(value, __x);}
1038 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1039 (const typename __Operation::second_argument_type& __x) const
1040 {return op(value, __x);}
1041};
1042
1043template <class __Operation, class _Tp>
1044inline _LIBCPP_INLINE_VISIBILITY
1045binder1st<__Operation>
1046bind1st(const __Operation& __op, const _Tp& __x)
1047 {return binder1st<__Operation>(__op, __x);}
1048
1049template <class __Operation>
Eric Fiselierc3589a82017-01-04 23:56:001050class _LIBCPP_TEMPLATE_VIS binder2nd
Howard Hinnantbc8d3f92010-05-11 19:42:161051 : public unary_function<typename __Operation::first_argument_type,
1052 typename __Operation::result_type>
1053{
1054protected:
1055 __Operation op;
1056 typename __Operation::second_argument_type value;
1057public:
Howard Hinnant42a63a72010-09-21 22:55:271058 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161059 binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y)
1060 : op(__x), value(__y) {}
1061 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1062 ( typename __Operation::first_argument_type& __x) const
1063 {return op(__x, value);}
1064 _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
1065 (const typename __Operation::first_argument_type& __x) const
1066 {return op(__x, value);}
1067};
1068
1069template <class __Operation, class _Tp>
1070inline _LIBCPP_INLINE_VISIBILITY
1071binder2nd<__Operation>
1072bind2nd(const __Operation& __op, const _Tp& __x)
1073 {return binder2nd<__Operation>(__op, __x);}
1074
1075template <class _Arg, class _Result>
Eric Fiselierc3589a82017-01-04 23:56:001076class _LIBCPP_TEMPLATE_VIS pointer_to_unary_function
Howard Hinnant42a63a72010-09-21 22:55:271077 : public unary_function<_Arg, _Result>
Howard Hinnantbc8d3f92010-05-11 19:42:161078{
1079 _Result (*__f_)(_Arg);
1080public:
1081 _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg))
1082 : __f_(__f) {}
1083 _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const
1084 {return __f_(__x);}
1085};
1086
1087template <class _Arg, class _Result>
1088inline _LIBCPP_INLINE_VISIBILITY
1089pointer_to_unary_function<_Arg,_Result>
1090ptr_fun(_Result (*__f)(_Arg))
1091 {return pointer_to_unary_function<_Arg,_Result>(__f);}
1092
1093template <class _Arg1, class _Arg2, class _Result>
Eric Fiselierc3589a82017-01-04 23:56:001094class _LIBCPP_TEMPLATE_VIS pointer_to_binary_function
Howard Hinnant42a63a72010-09-21 22:55:271095 : public binary_function<_Arg1, _Arg2, _Result>
Howard Hinnantbc8d3f92010-05-11 19:42:161096{
1097 _Result (*__f_)(_Arg1, _Arg2);
1098public:
1099 _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2))
1100 : __f_(__f) {}
1101 _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const
1102 {return __f_(__x, __y);}
1103};
1104
1105template <class _Arg1, class _Arg2, class _Result>
1106inline _LIBCPP_INLINE_VISIBILITY
1107pointer_to_binary_function<_Arg1,_Arg2,_Result>
1108ptr_fun(_Result (*__f)(_Arg1,_Arg2))
1109 {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);}
1110
1111template<class _Sp, class _Tp>
Eric Fiselierc3589a82017-01-04 23:56:001112class _LIBCPP_TEMPLATE_VIS mem_fun_t : public unary_function<_Tp*, _Sp>
Howard Hinnantbc8d3f92010-05-11 19:42:161113{
1114 _Sp (_Tp::*__p_)();
1115public:
1116 _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)())
1117 : __p_(__p) {}
1118 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const
1119 {return (__p->*__p_)();}
1120};
1121
1122template<class _Sp, class _Tp, class _Ap>
Eric Fiselierc3589a82017-01-04 23:56:001123class _LIBCPP_TEMPLATE_VIS mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp>
Howard Hinnantbc8d3f92010-05-11 19:42:161124{
1125 _Sp (_Tp::*__p_)(_Ap);
1126public:
1127 _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap))
1128 : __p_(__p) {}
1129 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const
1130 {return (__p->*__p_)(__x);}
1131};
1132
1133template<class _Sp, class _Tp>
1134inline _LIBCPP_INLINE_VISIBILITY
1135mem_fun_t<_Sp,_Tp>
1136mem_fun(_Sp (_Tp::*__f)())
1137 {return mem_fun_t<_Sp,_Tp>(__f);}
1138
1139template<class _Sp, class _Tp, class _Ap>
1140inline _LIBCPP_INLINE_VISIBILITY
1141mem_fun1_t<_Sp,_Tp,_Ap>
1142mem_fun(_Sp (_Tp::*__f)(_Ap))
1143 {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
1144
1145template<class _Sp, class _Tp>
Eric Fiselierc3589a82017-01-04 23:56:001146class _LIBCPP_TEMPLATE_VIS mem_fun_ref_t : public unary_function<_Tp, _Sp>
Howard Hinnantbc8d3f92010-05-11 19:42:161147{
1148 _Sp (_Tp::*__p_)();
1149public:
1150 _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)())
1151 : __p_(__p) {}
1152 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const
1153 {return (__p.*__p_)();}
1154};
1155
1156template<class _Sp, class _Tp, class _Ap>
Eric Fiselierc3589a82017-01-04 23:56:001157class _LIBCPP_TEMPLATE_VIS mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp>
Howard Hinnantbc8d3f92010-05-11 19:42:161158{
1159 _Sp (_Tp::*__p_)(_Ap);
1160public:
1161 _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap))
1162 : __p_(__p) {}
1163 _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const
1164 {return (__p.*__p_)(__x);}
1165};
1166
1167template<class _Sp, class _Tp>
1168inline _LIBCPP_INLINE_VISIBILITY
1169mem_fun_ref_t<_Sp,_Tp>
1170mem_fun_ref(_Sp (_Tp::*__f)())
1171 {return mem_fun_ref_t<_Sp,_Tp>(__f);}
1172
1173template<class _Sp, class _Tp, class _Ap>
1174inline _LIBCPP_INLINE_VISIBILITY
1175mem_fun1_ref_t<_Sp,_Tp,_Ap>
1176mem_fun_ref(_Sp (_Tp::*__f)(_Ap))
1177 {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
1178
1179template <class _Sp, class _Tp>
Eric Fiselierc3589a82017-01-04 23:56:001180class _LIBCPP_TEMPLATE_VIS const_mem_fun_t : public unary_function<const _Tp*, _Sp>
Howard Hinnantbc8d3f92010-05-11 19:42:161181{
1182 _Sp (_Tp::*__p_)() const;
1183public:
1184 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const)
1185 : __p_(__p) {}
1186 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const
1187 {return (__p->*__p_)();}
1188};
1189
1190template <class _Sp, class _Tp, class _Ap>
Eric Fiselierc3589a82017-01-04 23:56:001191class _LIBCPP_TEMPLATE_VIS const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp>
Howard Hinnantbc8d3f92010-05-11 19:42:161192{
1193 _Sp (_Tp::*__p_)(_Ap) const;
1194public:
1195 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const)
1196 : __p_(__p) {}
1197 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const
1198 {return (__p->*__p_)(__x);}
1199};
1200
1201template <class _Sp, class _Tp>
1202inline _LIBCPP_INLINE_VISIBILITY
1203const_mem_fun_t<_Sp,_Tp>
1204mem_fun(_Sp (_Tp::*__f)() const)
1205 {return const_mem_fun_t<_Sp,_Tp>(__f);}
1206
1207template <class _Sp, class _Tp, class _Ap>
1208inline _LIBCPP_INLINE_VISIBILITY
1209const_mem_fun1_t<_Sp,_Tp,_Ap>
1210mem_fun(_Sp (_Tp::*__f)(_Ap) const)
1211 {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
1212
1213template <class _Sp, class _Tp>
Eric Fiselierc3589a82017-01-04 23:56:001214class _LIBCPP_TEMPLATE_VIS const_mem_fun_ref_t : public unary_function<_Tp, _Sp>
Howard Hinnantbc8d3f92010-05-11 19:42:161215{
1216 _Sp (_Tp::*__p_)() const;
1217public:
1218 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const)
1219 : __p_(__p) {}
1220 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const
1221 {return (__p.*__p_)();}
1222};
1223
1224template <class _Sp, class _Tp, class _Ap>
Eric Fiselierc3589a82017-01-04 23:56:001225class _LIBCPP_TEMPLATE_VIS const_mem_fun1_ref_t
Howard Hinnant42a63a72010-09-21 22:55:271226 : public binary_function<_Tp, _Ap, _Sp>
Howard Hinnantbc8d3f92010-05-11 19:42:161227{
1228 _Sp (_Tp::*__p_)(_Ap) const;
1229public:
1230 _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const)
1231 : __p_(__p) {}
1232 _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const
1233 {return (__p.*__p_)(__x);}
1234};
1235
1236template <class _Sp, class _Tp>
1237inline _LIBCPP_INLINE_VISIBILITY
1238const_mem_fun_ref_t<_Sp,_Tp>
1239mem_fun_ref(_Sp (_Tp::*__f)() const)
1240 {return const_mem_fun_ref_t<_Sp,_Tp>(__f);}
1241
1242template <class _Sp, class _Tp, class _Ap>
1243inline _LIBCPP_INLINE_VISIBILITY
1244const_mem_fun1_ref_t<_Sp,_Tp,_Ap>
1245mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const)
1246 {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
1247
Eric Fiselier45f63bc2015-07-22 04:14:381248////////////////////////////////////////////////////////////////////////////////
1249// MEMFUN
1250//==============================================================================
Howard Hinnantbc8d3f92010-05-11 19:42:161251
Howard Hinnantbc8d3f92010-05-11 19:42:161252template <class _Tp>
1253class __mem_fn
1254 : public __weak_result_type<_Tp>
1255{
1256public:
1257 // types
1258 typedef _Tp type;
1259private:
1260 type __f_;
1261
1262public:
Marshall Clowfb7b97c2015-10-25 20:12:161263 _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
Howard Hinnantbc8d3f92010-05-11 19:42:161264
Eric Fiselierdb8c4fd2015-07-22 22:43:271265#ifndef _LIBCPP_HAS_NO_VARIADICS
Howard Hinnantbc8d3f92010-05-11 19:42:161266 // invoke
1267 template <class... _ArgTypes>
Eric Fiselierdb8c4fd2015-07-22 22:43:271268 _LIBCPP_INLINE_VISIBILITY
1269 typename __invoke_return<type, _ArgTypes...>::type
1270 operator() (_ArgTypes&&... __args) const {
1271 return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
1272 }
1273#else
Eric Fiselierdb8c4fd2015-07-22 22:43:271274
1275 template <class _A0>
Eric Fiselierf1626ad2015-08-26 20:15:021276 _LIBCPP_INLINE_VISIBILITY
Eric Fiselierdb8c4fd2015-07-22 22:43:271277 typename __invoke_return0<type, _A0>::type
1278 operator() (_A0& __a0) const {
1279 return __invoke(__f_, __a0);
1280 }
1281
Eric Fiselierf1626ad2015-08-26 20:15:021282 template <class _A0>
1283 _LIBCPP_INLINE_VISIBILITY
1284 typename __invoke_return0<type, _A0 const>::type
1285 operator() (_A0 const& __a0) const {
1286 return __invoke(__f_, __a0);
1287 }
1288
Eric Fiselierdb8c4fd2015-07-22 22:43:271289 template <class _A0, class _A1>
Eric Fiselierf1626ad2015-08-26 20:15:021290 _LIBCPP_INLINE_VISIBILITY
Eric Fiselierdb8c4fd2015-07-22 22:43:271291 typename __invoke_return1<type, _A0, _A1>::type
1292 operator() (_A0& __a0, _A1& __a1) const {
1293 return __invoke(__f_, __a0, __a1);
1294 }
1295
Eric Fiselierf1626ad2015-08-26 20:15:021296 template <class _A0, class _A1>
1297 _LIBCPP_INLINE_VISIBILITY
1298 typename __invoke_return1<type, _A0 const, _A1>::type
1299 operator() (_A0 const& __a0, _A1& __a1) const {
1300 return __invoke(__f_, __a0, __a1);
1301 }
1302
1303 template <class _A0, class _A1>
1304 _LIBCPP_INLINE_VISIBILITY
1305 typename __invoke_return1<type, _A0, _A1 const>::type
1306 operator() (_A0& __a0, _A1 const& __a1) const {
1307 return __invoke(__f_, __a0, __a1);
1308 }
1309
1310 template <class _A0, class _A1>
1311 _LIBCPP_INLINE_VISIBILITY
1312 typename __invoke_return1<type, _A0 const, _A1 const>::type
1313 operator() (_A0 const& __a0, _A1 const& __a1) const {
1314 return __invoke(__f_, __a0, __a1);
1315 }
1316
Eric Fiselierdb8c4fd2015-07-22 22:43:271317 template <class _A0, class _A1, class _A2>
Eric Fiselierf1626ad2015-08-26 20:15:021318 _LIBCPP_INLINE_VISIBILITY
Eric Fiselierdb8c4fd2015-07-22 22:43:271319 typename __invoke_return2<type, _A0, _A1, _A2>::type
1320 operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
1321 return __invoke(__f_, __a0, __a1, __a2);
1322 }
Eric Fiselierf1626ad2015-08-26 20:15:021323
1324 template <class _A0, class _A1, class _A2>
1325 _LIBCPP_INLINE_VISIBILITY
1326 typename __invoke_return2<type, _A0 const, _A1, _A2>::type
1327 operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
1328 return __invoke(__f_, __a0, __a1, __a2);
1329 }
1330
1331 template <class _A0, class _A1, class _A2>
1332 _LIBCPP_INLINE_VISIBILITY
1333 typename __invoke_return2<type, _A0, _A1 const, _A2>::type
1334 operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
1335 return __invoke(__f_, __a0, __a1, __a2);
1336 }
1337
1338 template <class _A0, class _A1, class _A2>
1339 _LIBCPP_INLINE_VISIBILITY
1340 typename __invoke_return2<type, _A0, _A1, _A2 const>::type
1341 operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
1342 return __invoke(__f_, __a0, __a1, __a2);
1343 }
1344
1345 template <class _A0, class _A1, class _A2>
1346 _LIBCPP_INLINE_VISIBILITY
1347 typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
1348 operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
1349 return __invoke(__f_, __a0, __a1, __a2);
1350 }
1351
1352 template <class _A0, class _A1, class _A2>
1353 _LIBCPP_INLINE_VISIBILITY
1354 typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
1355 operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
1356 return __invoke(__f_, __a0, __a1, __a2);
1357 }
1358
1359 template <class _A0, class _A1, class _A2>
1360 _LIBCPP_INLINE_VISIBILITY
1361 typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
1362 operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
1363 return __invoke(__f_, __a0, __a1, __a2);
1364 }
1365
1366 template <class _A0, class _A1, class _A2>
1367 _LIBCPP_INLINE_VISIBILITY
1368 typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
1369 operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
1370 return __invoke(__f_, __a0, __a1, __a2);
1371 }
Eric Fiselierdb8c4fd2015-07-22 22:43:271372#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161373};
1374
Howard Hinnant99968442011-11-29 18:15:501375template<class _Rp, class _Tp>
Howard Hinnantbc8d3f92010-05-11 19:42:161376inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnant99968442011-11-29 18:15:501377__mem_fn<_Rp _Tp::*>
Marshall Clowfb7b97c2015-10-25 20:12:161378mem_fn(_Rp _Tp::* __pm) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:161379{
Howard Hinnant99968442011-11-29 18:15:501380 return __mem_fn<_Rp _Tp::*>(__pm);
Howard Hinnantbc8d3f92010-05-11 19:42:161381}
1382
Eric Fiselier45f63bc2015-07-22 04:14:381383////////////////////////////////////////////////////////////////////////////////
1384// FUNCTION
1385//==============================================================================
1386
Howard Hinnantbc8d3f92010-05-11 19:42:161387// bad_function_call
1388
Howard Hinnant42a63a72010-09-21 22:55:271389class _LIBCPP_EXCEPTION_ABI bad_function_call
Howard Hinnantbc8d3f92010-05-11 19:42:161390 : public exception
1391{
1392};
1393
Marshall Clow14c09a22016-08-25 15:09:011394_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
1395void __throw_bad_function_call()
1396{
1397#ifndef _LIBCPP_NO_EXCEPTIONS
1398 throw bad_function_call();
1399#else
1400_VSTD::abort();
1401#endif
1402}
1403
Eric Fiselierc3589a82017-01-04 23:56:001404template<class _Fp> class _LIBCPP_TEMPLATE_VIS function; // undefined
Howard Hinnantbc8d3f92010-05-11 19:42:161405
1406namespace __function
1407{
1408
Eric Fiselier45f63bc2015-07-22 04:14:381409template<class _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:161410struct __maybe_derive_from_unary_function
1411{
1412};
1413
Howard Hinnant99968442011-11-29 18:15:501414template<class _Rp, class _A1>
1415struct __maybe_derive_from_unary_function<_Rp(_A1)>
1416 : public unary_function<_A1, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:161417{
1418};
1419
Eric Fiselier45f63bc2015-07-22 04:14:381420template<class _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:161421struct __maybe_derive_from_binary_function
1422{
1423};
1424
Howard Hinnant99968442011-11-29 18:15:501425template<class _Rp, class _A1, class _A2>
1426struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
1427 : public binary_function<_A1, _A2, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:161428{
1429};
1430
Eric Fiselier8e030712015-08-18 19:41:511431template <class _Fp>
1432_LIBCPP_INLINE_VISIBILITY
1433bool __not_null(_Fp const&) { return true; }
1434
1435template <class _Fp>
1436_LIBCPP_INLINE_VISIBILITY
1437bool __not_null(_Fp* __ptr) { return __ptr; }
1438
1439template <class _Ret, class _Class>
1440_LIBCPP_INLINE_VISIBILITY
1441bool __not_null(_Ret _Class::*__ptr) { return __ptr; }
1442
1443template <class _Fp>
1444_LIBCPP_INLINE_VISIBILITY
1445bool __not_null(function<_Fp> const& __f) { return !!__f; }
1446
Eric Fiselier45f63bc2015-07-22 04:14:381447} // namespace __function
1448
1449#ifndef _LIBCPP_HAS_NO_VARIADICS
1450
1451namespace __function {
1452
Howard Hinnantbc8d3f92010-05-11 19:42:161453template<class _Fp> class __base;
1454
Howard Hinnant99968442011-11-29 18:15:501455template<class _Rp, class ..._ArgTypes>
1456class __base<_Rp(_ArgTypes...)>
Howard Hinnantbc8d3f92010-05-11 19:42:161457{
1458 __base(const __base&);
1459 __base& operator=(const __base&);
1460public:
Howard Hinnant42a63a72010-09-21 22:55:271461 _LIBCPP_INLINE_VISIBILITY __base() {}
1462 _LIBCPP_INLINE_VISIBILITY virtual ~__base() {}
Howard Hinnantbc8d3f92010-05-11 19:42:161463 virtual __base* __clone() const = 0;
1464 virtual void __clone(__base*) const = 0;
Howard Hinnant603d2c02011-05-28 17:59:481465 virtual void destroy() _NOEXCEPT = 0;
1466 virtual void destroy_deallocate() _NOEXCEPT = 0;
Howard Hinnant99968442011-11-29 18:15:501467 virtual _Rp operator()(_ArgTypes&& ...) = 0;
Howard Hinnantd4444702010-08-11 17:04:311468#ifndef _LIBCPP_NO_RTTI
Howard Hinnant603d2c02011-05-28 17:59:481469 virtual const void* target(const type_info&) const _NOEXCEPT = 0;
1470 virtual const std::type_info& target_type() const _NOEXCEPT = 0;
Howard Hinnant324bb032010-08-22 00:02:431471#endif // _LIBCPP_NO_RTTI
Howard Hinnantbc8d3f92010-05-11 19:42:161472};
1473
1474template<class _FD, class _Alloc, class _FB> class __func;
1475
Howard Hinnant99968442011-11-29 18:15:501476template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1477class __func<_Fp, _Alloc, _Rp(_ArgTypes...)>
1478 : public __base<_Rp(_ArgTypes...)>
Howard Hinnantbc8d3f92010-05-11 19:42:161479{
Howard Hinnant99968442011-11-29 18:15:501480 __compressed_pair<_Fp, _Alloc> __f_;
Howard Hinnantbc8d3f92010-05-11 19:42:161481public:
Howard Hinnant42a63a72010-09-21 22:55:271482 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4a13b2d2012-02-28 19:47:381483 explicit __func(_Fp&& __f)
1484 : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
1485 _VSTD::forward_as_tuple()) {}
Howard Hinnant42a63a72010-09-21 22:55:271486 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4a13b2d2012-02-28 19:47:381487 explicit __func(const _Fp& __f, const _Alloc& __a)
1488 : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
1489 _VSTD::forward_as_tuple(__a)) {}
1490
1491 _LIBCPP_INLINE_VISIBILITY
1492 explicit __func(const _Fp& __f, _Alloc&& __a)
1493 : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
1494 _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
1495
1496 _LIBCPP_INLINE_VISIBILITY
1497 explicit __func(_Fp&& __f, _Alloc&& __a)
1498 : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
1499 _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
Howard Hinnant99968442011-11-29 18:15:501500 virtual __base<_Rp(_ArgTypes...)>* __clone() const;
1501 virtual void __clone(__base<_Rp(_ArgTypes...)>*) const;
Howard Hinnant603d2c02011-05-28 17:59:481502 virtual void destroy() _NOEXCEPT;
1503 virtual void destroy_deallocate() _NOEXCEPT;
Howard Hinnant99968442011-11-29 18:15:501504 virtual _Rp operator()(_ArgTypes&& ... __arg);
Howard Hinnantd4444702010-08-11 17:04:311505#ifndef _LIBCPP_NO_RTTI
Howard Hinnant603d2c02011-05-28 17:59:481506 virtual const void* target(const type_info&) const _NOEXCEPT;
1507 virtual const std::type_info& target_type() const _NOEXCEPT;
Howard Hinnant324bb032010-08-22 00:02:431508#endif // _LIBCPP_NO_RTTI
Howard Hinnantbc8d3f92010-05-11 19:42:161509};
1510
Howard Hinnant99968442011-11-29 18:15:501511template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1512__base<_Rp(_ArgTypes...)>*
1513__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
Howard Hinnantbc8d3f92010-05-11 19:42:161514{
Eric Fiselier71aa3762015-03-18 22:56:501515 typedef allocator_traits<_Alloc> __alloc_traits;
Marshall Clow66302c62015-04-07 05:21:381516 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
Howard Hinnant99968442011-11-29 18:15:501517 _Ap __a(__f_.second());
1518 typedef __allocator_destructor<_Ap> _Dp;
1519 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
Howard Hinnantbc8d3f92010-05-11 19:42:161520 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
1521 return __hold.release();
1522}
1523
Howard Hinnant99968442011-11-29 18:15:501524template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
Howard Hinnantbc8d3f92010-05-11 19:42:161525void
Howard Hinnant99968442011-11-29 18:15:501526__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
Howard Hinnantbc8d3f92010-05-11 19:42:161527{
1528 ::new (__p) __func(__f_.first(), __f_.second());
1529}
1530
Howard Hinnant99968442011-11-29 18:15:501531template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
Howard Hinnantbc8d3f92010-05-11 19:42:161532void
Howard Hinnant99968442011-11-29 18:15:501533__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:161534{
Howard Hinnant99968442011-11-29 18:15:501535 __f_.~__compressed_pair<_Fp, _Alloc>();
Howard Hinnantbc8d3f92010-05-11 19:42:161536}
1537
Howard Hinnant99968442011-11-29 18:15:501538template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
Howard Hinnantbc8d3f92010-05-11 19:42:161539void
Howard Hinnant99968442011-11-29 18:15:501540__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:161541{
Eric Fiselier71aa3762015-03-18 22:56:501542 typedef allocator_traits<_Alloc> __alloc_traits;
Marshall Clow66302c62015-04-07 05:21:381543 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
Howard Hinnant99968442011-11-29 18:15:501544 _Ap __a(__f_.second());
1545 __f_.~__compressed_pair<_Fp, _Alloc>();
Howard Hinnantbc8d3f92010-05-11 19:42:161546 __a.deallocate(this, 1);
1547}
1548
Howard Hinnant99968442011-11-29 18:15:501549template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
1550_Rp
1551__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
Howard Hinnantbc8d3f92010-05-11 19:42:161552{
Eric Fiselierc3231d22015-02-10 16:48:451553 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
1554 return _Invoker::__call(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...);
Howard Hinnantbc8d3f92010-05-11 19:42:161555}
1556
Howard Hinnantd4444702010-08-11 17:04:311557#ifndef _LIBCPP_NO_RTTI
1558
Howard Hinnant99968442011-11-29 18:15:501559template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
Howard Hinnantbc8d3f92010-05-11 19:42:161560const void*
Howard Hinnant99968442011-11-29 18:15:501561__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:161562{
Howard Hinnant99968442011-11-29 18:15:501563 if (__ti == typeid(_Fp))
Howard Hinnantbc8d3f92010-05-11 19:42:161564 return &__f_.first();
1565 return (const void*)0;
1566}
1567
Howard Hinnant99968442011-11-29 18:15:501568template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
Howard Hinnantbc8d3f92010-05-11 19:42:161569const std::type_info&
Howard Hinnant99968442011-11-29 18:15:501570__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:161571{
Howard Hinnant99968442011-11-29 18:15:501572 return typeid(_Fp);
Howard Hinnantbc8d3f92010-05-11 19:42:161573}
1574
Howard Hinnant324bb032010-08-22 00:02:431575#endif // _LIBCPP_NO_RTTI
Howard Hinnantd4444702010-08-11 17:04:311576
Howard Hinnantbc8d3f92010-05-11 19:42:161577} // __function
1578
Howard Hinnant99968442011-11-29 18:15:501579template<class _Rp, class ..._ArgTypes>
Eric Fiselierc3589a82017-01-04 23:56:001580class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
Howard Hinnant99968442011-11-29 18:15:501581 : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
1582 public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>
Howard Hinnantbc8d3f92010-05-11 19:42:161583{
Howard Hinnant99968442011-11-29 18:15:501584 typedef __function::__base<_Rp(_ArgTypes...)> __base;
Howard Hinnant78f0de22013-01-21 17:26:551585 typename aligned_storage<3*sizeof(void*)>::type __buf_;
Howard Hinnantbc8d3f92010-05-11 19:42:161586 __base* __f_;
1587
Evgeniy Stepanov45dca2c2016-02-10 21:53:281588 _LIBCPP_NO_CFI static __base *__as_base(void *p) {
1589 return reinterpret_cast<__base*>(p);
1590 }
1591
Howard Hinnante41f4752012-07-20 18:56:071592 template <class _Fp, bool = !is_same<_Fp, function>::value &&
1593 __invokable<_Fp&, _ArgTypes...>::value>
Howard Hinnant083ba5f2011-05-31 21:45:261594 struct __callable;
Howard Hinnant99968442011-11-29 18:15:501595 template <class _Fp>
1596 struct __callable<_Fp, true>
Howard Hinnant083ba5f2011-05-31 21:45:261597 {
Eric Fiselierc3231d22015-02-10 16:48:451598 static const bool value = is_same<void, _Rp>::value ||
Howard Hinnant99968442011-11-29 18:15:501599 is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type,
1600 _Rp>::value;
Howard Hinnant083ba5f2011-05-31 21:45:261601 };
Howard Hinnant99968442011-11-29 18:15:501602 template <class _Fp>
1603 struct __callable<_Fp, false>
Howard Hinnant083ba5f2011-05-31 21:45:261604 {
1605 static const bool value = false;
1606 };
Howard Hinnantbc8d3f92010-05-11 19:42:161607public:
Howard Hinnant99968442011-11-29 18:15:501608 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:161609
Howard Hinnant72552802010-08-20 19:36:461610 // construct/copy/destroy:
Howard Hinnant42a63a72010-09-21 22:55:271611 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant603d2c02011-05-28 17:59:481612 function() _NOEXCEPT : __f_(0) {}
Howard Hinnant42a63a72010-09-21 22:55:271613 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant603d2c02011-05-28 17:59:481614 function(nullptr_t) _NOEXCEPT : __f_(0) {}
Howard Hinnantbc8d3f92010-05-11 19:42:161615 function(const function&);
Howard Hinnant603d2c02011-05-28 17:59:481616 function(function&&) _NOEXCEPT;
Eric Fiselier16ed7182016-07-20 05:21:001617 template<class _Fp, class = typename enable_if<
1618 __callable<_Fp>::value && !is_same<_Fp, function>::value
1619 >::type>
1620 function(_Fp);
Howard Hinnantbc8d3f92010-05-11 19:42:161621
Marshall Clowe29fb4c2016-10-13 21:06:031622#if _LIBCPP_STD_VER <= 14
Howard Hinnant72552802010-08-20 19:36:461623 template<class _Alloc>
Howard Hinnant42a63a72010-09-21 22:55:271624 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant603d2c02011-05-28 17:59:481625 function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {}
Howard Hinnant72552802010-08-20 19:36:461626 template<class _Alloc>
Howard Hinnant42a63a72010-09-21 22:55:271627 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant603d2c02011-05-28 17:59:481628 function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {}
Howard Hinnant72552802010-08-20 19:36:461629 template<class _Alloc>
1630 function(allocator_arg_t, const _Alloc&, const function&);
1631 template<class _Alloc>
1632 function(allocator_arg_t, const _Alloc&, function&&);
Eric Fiselier16ed7182016-07-20 05:21:001633 template<class _Fp, class _Alloc, class = typename enable_if<__callable<_Fp>::value>::type>
1634 function(allocator_arg_t, const _Alloc& __a, _Fp __f);
Marshall Clowe29fb4c2016-10-13 21:06:031635#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161636
1637 function& operator=(const function&);
Howard Hinnant603d2c02011-05-28 17:59:481638 function& operator=(function&&) _NOEXCEPT;
1639 function& operator=(nullptr_t) _NOEXCEPT;
Howard Hinnant99968442011-11-29 18:15:501640 template<class _Fp>
Howard Hinnantbc8d3f92010-05-11 19:42:161641 typename enable_if
1642 <
Howard Hinnant099dec12013-07-01 00:01:511643 __callable<typename decay<_Fp>::type>::value &&
1644 !is_same<typename remove_reference<_Fp>::type, function>::value,
Howard Hinnantbc8d3f92010-05-11 19:42:161645 function&
1646 >::type
Howard Hinnant99968442011-11-29 18:15:501647 operator=(_Fp&&);
Howard Hinnantbc8d3f92010-05-11 19:42:161648
1649 ~function();
1650
Howard Hinnant72552802010-08-20 19:36:461651 // function modifiers:
Howard Hinnant603d2c02011-05-28 17:59:481652 void swap(function&) _NOEXCEPT;
Marshall Clow73de8802016-01-25 17:29:551653
1654#if _LIBCPP_STD_VER <= 14
Howard Hinnant99968442011-11-29 18:15:501655 template<class _Fp, class _Alloc>
Howard Hinnant42a63a72010-09-21 22:55:271656 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant99968442011-11-29 18:15:501657 void assign(_Fp&& __f, const _Alloc& __a)
1658 {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);}
Marshall Clow73de8802016-01-25 17:29:551659#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161660
Howard Hinnant72552802010-08-20 19:36:461661 // function capacity:
Howard Hinnant42a63a72010-09-21 22:55:271662 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant77861882012-02-21 21:46:431663 _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;}
Howard Hinnantbc8d3f92010-05-11 19:42:161664
Howard Hinnantbc8d3f92010-05-11 19:42:161665 // deleted overloads close possible hole in the type system
1666 template<class _R2, class... _ArgTypes2>
Howard Hinnanta0f1dc92010-09-11 15:33:211667 bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete;
Howard Hinnantbc8d3f92010-05-11 19:42:161668 template<class _R2, class... _ArgTypes2>
Howard Hinnanta0f1dc92010-09-11 15:33:211669 bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete;
Howard Hinnantbc8d3f92010-05-11 19:42:161670public:
Howard Hinnant72552802010-08-20 19:36:461671 // function invocation:
Howard Hinnant99968442011-11-29 18:15:501672 _Rp operator()(_ArgTypes...) const;
Howard Hinnantbc8d3f92010-05-11 19:42:161673
Howard Hinnantd4444702010-08-11 17:04:311674#ifndef _LIBCPP_NO_RTTI
Howard Hinnant72552802010-08-20 19:36:461675 // function target access:
Howard Hinnant603d2c02011-05-28 17:59:481676 const std::type_info& target_type() const _NOEXCEPT;
Howard Hinnant99968442011-11-29 18:15:501677 template <typename _Tp> _Tp* target() _NOEXCEPT;
1678 template <typename _Tp> const _Tp* target() const _NOEXCEPT;
Howard Hinnant324bb032010-08-22 00:02:431679#endif // _LIBCPP_NO_RTTI
Howard Hinnantbc8d3f92010-05-11 19:42:161680};
1681
Howard Hinnant99968442011-11-29 18:15:501682template<class _Rp, class ..._ArgTypes>
1683function<_Rp(_ArgTypes...)>::function(const function& __f)
Howard Hinnantbc8d3f92010-05-11 19:42:161684{
1685 if (__f.__f_ == 0)
1686 __f_ = 0;
Evgeniy Stepanov45dca2c2016-02-10 21:53:281687 else if ((void *)__f.__f_ == &__f.__buf_)
Howard Hinnantbc8d3f92010-05-11 19:42:161688 {
Evgeniy Stepanov45dca2c2016-02-10 21:53:281689 __f_ = __as_base(&__buf_);
Howard Hinnantbc8d3f92010-05-11 19:42:161690 __f.__f_->__clone(__f_);
1691 }
1692 else
1693 __f_ = __f.__f_->__clone();
1694}
1695
Marshall Clowe29fb4c2016-10-13 21:06:031696#if _LIBCPP_STD_VER <= 14
Howard Hinnant99968442011-11-29 18:15:501697template<class _Rp, class ..._ArgTypes>
Howard Hinnant72552802010-08-20 19:36:461698template <class _Alloc>
Howard Hinnant99968442011-11-29 18:15:501699function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
Howard Hinnant72552802010-08-20 19:36:461700 const function& __f)
1701{
1702 if (__f.__f_ == 0)
1703 __f_ = 0;
Evgeniy Stepanov45dca2c2016-02-10 21:53:281704 else if ((void *)__f.__f_ == &__f.__buf_)
Howard Hinnant72552802010-08-20 19:36:461705 {
Evgeniy Stepanov45dca2c2016-02-10 21:53:281706 __f_ = __as_base(&__buf_);
Howard Hinnant72552802010-08-20 19:36:461707 __f.__f_->__clone(__f_);
1708 }
1709 else
1710 __f_ = __f.__f_->__clone();
1711}
Marshall Clowe29fb4c2016-10-13 21:06:031712#endif
Howard Hinnant72552802010-08-20 19:36:461713
Howard Hinnant99968442011-11-29 18:15:501714template<class _Rp, class ..._ArgTypes>
1715function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:161716{
1717 if (__f.__f_ == 0)
1718 __f_ = 0;
Evgeniy Stepanov45dca2c2016-02-10 21:53:281719 else if ((void *)__f.__f_ == &__f.__buf_)
Howard Hinnantbc8d3f92010-05-11 19:42:161720 {
Evgeniy Stepanov45dca2c2016-02-10 21:53:281721 __f_ = __as_base(&__buf_);
Howard Hinnantbc8d3f92010-05-11 19:42:161722 __f.__f_->__clone(__f_);
1723 }
1724 else
1725 {
1726 __f_ = __f.__f_;
1727 __f.__f_ = 0;
1728 }
1729}
1730
Marshall Clowe29fb4c2016-10-13 21:06:031731#if _LIBCPP_STD_VER <= 14
Howard Hinnant99968442011-11-29 18:15:501732template<class _Rp, class ..._ArgTypes>
Howard Hinnant72552802010-08-20 19:36:461733template <class _Alloc>
Howard Hinnant99968442011-11-29 18:15:501734function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
Howard Hinnant72552802010-08-20 19:36:461735 function&& __f)
1736{
1737 if (__f.__f_ == 0)
1738 __f_ = 0;
Evgeniy Stepanov45dca2c2016-02-10 21:53:281739 else if ((void *)__f.__f_ == &__f.__buf_)
Howard Hinnant72552802010-08-20 19:36:461740 {
Evgeniy Stepanov45dca2c2016-02-10 21:53:281741 __f_ = __as_base(&__buf_);
Howard Hinnant72552802010-08-20 19:36:461742 __f.__f_->__clone(__f_);
1743 }
1744 else
1745 {
1746 __f_ = __f.__f_;
1747 __f.__f_ = 0;
1748 }
1749}
Marshall Clowe29fb4c2016-10-13 21:06:031750#endif
Howard Hinnant72552802010-08-20 19:36:461751
Howard Hinnant99968442011-11-29 18:15:501752template<class _Rp, class ..._ArgTypes>
Eric Fiselier16ed7182016-07-20 05:21:001753template <class _Fp, class>
1754function<_Rp(_ArgTypes...)>::function(_Fp __f)
Howard Hinnantbc8d3f92010-05-11 19:42:161755 : __f_(0)
1756{
Eric Fiselier8e030712015-08-18 19:41:511757 if (__function::__not_null(__f))
Howard Hinnantbc8d3f92010-05-11 19:42:161758 {
Howard Hinnant99968442011-11-29 18:15:501759 typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF;
1760 if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:161761 {
Evgeniy Stepanov45dca2c2016-02-10 21:53:281762 __f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f));
Howard Hinnantbc8d3f92010-05-11 19:42:161763 }
1764 else
1765 {
Howard Hinnant99968442011-11-29 18:15:501766 typedef allocator<_FF> _Ap;
1767 _Ap __a;
1768 typedef __allocator_destructor<_Ap> _Dp;
1769 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1770 ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a));
Howard Hinnantbc8d3f92010-05-11 19:42:161771 __f_ = __hold.release();
1772 }
1773 }
1774}
1775
Marshall Clowe29fb4c2016-10-13 21:06:031776#if _LIBCPP_STD_VER <= 14
Howard Hinnant99968442011-11-29 18:15:501777template<class _Rp, class ..._ArgTypes>
Eric Fiselier16ed7182016-07-20 05:21:001778template <class _Fp, class _Alloc, class>
1779function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f)
Howard Hinnant72552802010-08-20 19:36:461780 : __f_(0)
1781{
1782 typedef allocator_traits<_Alloc> __alloc_traits;
Eric Fiselier8e030712015-08-18 19:41:511783 if (__function::__not_null(__f))
Howard Hinnant72552802010-08-20 19:36:461784 {
Howard Hinnant99968442011-11-29 18:15:501785 typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF;
Marshall Clow66302c62015-04-07 05:21:381786 typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
Marshall Clowa178c132014-04-18 17:23:361787 _Ap __a(__a0);
1788 if (sizeof(_FF) <= sizeof(__buf_) &&
1789 is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value)
Howard Hinnant72552802010-08-20 19:36:461790 {
Evgeniy Stepanov45dca2c2016-02-10 21:53:281791 __f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f), _Alloc(__a));
Howard Hinnant72552802010-08-20 19:36:461792 }
1793 else
1794 {
Howard Hinnant99968442011-11-29 18:15:501795 typedef __allocator_destructor<_Ap> _Dp;
1796 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
Howard Hinnant0949eed2011-06-30 21:18:191797 ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a));
Howard Hinnant72552802010-08-20 19:36:461798 __f_ = __hold.release();
1799 }
1800 }
1801}
Marshall Clowe29fb4c2016-10-13 21:06:031802#endif
Howard Hinnant72552802010-08-20 19:36:461803
Howard Hinnant99968442011-11-29 18:15:501804template<class _Rp, class ..._ArgTypes>
1805function<_Rp(_ArgTypes...)>&
1806function<_Rp(_ArgTypes...)>::operator=(const function& __f)
Howard Hinnantbc8d3f92010-05-11 19:42:161807{
1808 function(__f).swap(*this);
1809 return *this;
1810}
1811
Howard Hinnant99968442011-11-29 18:15:501812template<class _Rp, class ..._ArgTypes>
1813function<_Rp(_ArgTypes...)>&
1814function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:161815{
Evgeniy Stepanov45dca2c2016-02-10 21:53:281816 if ((void *)__f_ == &__buf_)
Howard Hinnantbc8d3f92010-05-11 19:42:161817 __f_->destroy();
1818 else if (__f_)
1819 __f_->destroy_deallocate();
1820 __f_ = 0;
1821 if (__f.__f_ == 0)
1822 __f_ = 0;
Evgeniy Stepanov45dca2c2016-02-10 21:53:281823 else if ((void *)__f.__f_ == &__f.__buf_)
Howard Hinnantbc8d3f92010-05-11 19:42:161824 {
Evgeniy Stepanov45dca2c2016-02-10 21:53:281825 __f_ = __as_base(&__buf_);
Howard Hinnantbc8d3f92010-05-11 19:42:161826 __f.__f_->__clone(__f_);
1827 }
1828 else
1829 {
1830 __f_ = __f.__f_;
1831 __f.__f_ = 0;
1832 }
Argyrios Kyrtzidis1dc6f7a2012-10-13 02:03:451833 return *this;
Howard Hinnantbc8d3f92010-05-11 19:42:161834}
1835
Howard Hinnant99968442011-11-29 18:15:501836template<class _Rp, class ..._ArgTypes>
1837function<_Rp(_ArgTypes...)>&
1838function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:161839{
Evgeniy Stepanov45dca2c2016-02-10 21:53:281840 if ((void *)__f_ == &__buf_)
Howard Hinnantbc8d3f92010-05-11 19:42:161841 __f_->destroy();
1842 else if (__f_)
1843 __f_->destroy_deallocate();
1844 __f_ = 0;
Argyrios Kyrtzidis1dc6f7a2012-10-13 02:03:451845 return *this;
Howard Hinnantbc8d3f92010-05-11 19:42:161846}
1847
Howard Hinnant99968442011-11-29 18:15:501848template<class _Rp, class ..._ArgTypes>
1849template <class _Fp>
Howard Hinnantbc8d3f92010-05-11 19:42:161850typename enable_if
1851<
Howard Hinnant099dec12013-07-01 00:01:511852 function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value &&
1853 !is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value,
Howard Hinnant99968442011-11-29 18:15:501854 function<_Rp(_ArgTypes...)>&
Howard Hinnantbc8d3f92010-05-11 19:42:161855>::type
Howard Hinnant99968442011-11-29 18:15:501856function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
Howard Hinnantbc8d3f92010-05-11 19:42:161857{
Howard Hinnant99968442011-11-29 18:15:501858 function(_VSTD::forward<_Fp>(__f)).swap(*this);
Howard Hinnantbc8d3f92010-05-11 19:42:161859 return *this;
1860}
1861
Howard Hinnant99968442011-11-29 18:15:501862template<class _Rp, class ..._ArgTypes>
1863function<_Rp(_ArgTypes...)>::~function()
Howard Hinnantbc8d3f92010-05-11 19:42:161864{
Evgeniy Stepanov45dca2c2016-02-10 21:53:281865 if ((void *)__f_ == &__buf_)
Howard Hinnantbc8d3f92010-05-11 19:42:161866 __f_->destroy();
1867 else if (__f_)
1868 __f_->destroy_deallocate();
1869}
1870
Howard Hinnant99968442011-11-29 18:15:501871template<class _Rp, class ..._ArgTypes>
Howard Hinnantbc8d3f92010-05-11 19:42:161872void
Howard Hinnant99968442011-11-29 18:15:501873function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:161874{
Eric Fiselier152e5e62016-12-29 20:03:551875 if (_VSTD::addressof(__f) == this)
1876 return;
Evgeniy Stepanov45dca2c2016-02-10 21:53:281877 if ((void *)__f_ == &__buf_ && (void *)__f.__f_ == &__f.__buf_)
Howard Hinnantbc8d3f92010-05-11 19:42:161878 {
1879 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
Evgeniy Stepanov45dca2c2016-02-10 21:53:281880 __base* __t = __as_base(&__tempbuf);
Howard Hinnantbc8d3f92010-05-11 19:42:161881 __f_->__clone(__t);
1882 __f_->destroy();
1883 __f_ = 0;
Evgeniy Stepanov45dca2c2016-02-10 21:53:281884 __f.__f_->__clone(__as_base(&__buf_));
Howard Hinnantbc8d3f92010-05-11 19:42:161885 __f.__f_->destroy();
1886 __f.__f_ = 0;
Evgeniy Stepanov45dca2c2016-02-10 21:53:281887 __f_ = __as_base(&__buf_);
1888 __t->__clone(__as_base(&__f.__buf_));
Howard Hinnantbc8d3f92010-05-11 19:42:161889 __t->destroy();
Evgeniy Stepanov45dca2c2016-02-10 21:53:281890 __f.__f_ = __as_base(&__f.__buf_);
Howard Hinnantbc8d3f92010-05-11 19:42:161891 }
Evgeniy Stepanov45dca2c2016-02-10 21:53:281892 else if ((void *)__f_ == &__buf_)
Howard Hinnantbc8d3f92010-05-11 19:42:161893 {
Evgeniy Stepanov45dca2c2016-02-10 21:53:281894 __f_->__clone(__as_base(&__f.__buf_));
Howard Hinnantbc8d3f92010-05-11 19:42:161895 __f_->destroy();
1896 __f_ = __f.__f_;
Evgeniy Stepanov45dca2c2016-02-10 21:53:281897 __f.__f_ = __as_base(&__f.__buf_);
Howard Hinnantbc8d3f92010-05-11 19:42:161898 }
Evgeniy Stepanov45dca2c2016-02-10 21:53:281899 else if ((void *)__f.__f_ == &__f.__buf_)
Howard Hinnantbc8d3f92010-05-11 19:42:161900 {
Evgeniy Stepanov45dca2c2016-02-10 21:53:281901 __f.__f_->__clone(__as_base(&__buf_));
Howard Hinnantbc8d3f92010-05-11 19:42:161902 __f.__f_->destroy();
1903 __f.__f_ = __f_;
Evgeniy Stepanov45dca2c2016-02-10 21:53:281904 __f_ = __as_base(&__buf_);
Howard Hinnantbc8d3f92010-05-11 19:42:161905 }
1906 else
Howard Hinnant0949eed2011-06-30 21:18:191907 _VSTD::swap(__f_, __f.__f_);
Howard Hinnantbc8d3f92010-05-11 19:42:161908}
1909
Howard Hinnant99968442011-11-29 18:15:501910template<class _Rp, class ..._ArgTypes>
1911_Rp
1912function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
Howard Hinnantbc8d3f92010-05-11 19:42:161913{
1914 if (__f_ == 0)
Marshall Clow14c09a22016-08-25 15:09:011915 __throw_bad_function_call();
Howard Hinnant0949eed2011-06-30 21:18:191916 return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...);
Howard Hinnantbc8d3f92010-05-11 19:42:161917}
1918
Howard Hinnantd4444702010-08-11 17:04:311919#ifndef _LIBCPP_NO_RTTI
1920
Howard Hinnant99968442011-11-29 18:15:501921template<class _Rp, class ..._ArgTypes>
Howard Hinnantbc8d3f92010-05-11 19:42:161922const std::type_info&
Howard Hinnant99968442011-11-29 18:15:501923function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:161924{
1925 if (__f_ == 0)
1926 return typeid(void);
1927 return __f_->target_type();
1928}
1929
Howard Hinnant99968442011-11-29 18:15:501930template<class _Rp, class ..._ArgTypes>
1931template <typename _Tp>
1932_Tp*
1933function<_Rp(_ArgTypes...)>::target() _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:161934{
1935 if (__f_ == 0)
Howard Hinnant99968442011-11-29 18:15:501936 return (_Tp*)0;
1937 return (_Tp*)__f_->target(typeid(_Tp));
Howard Hinnantbc8d3f92010-05-11 19:42:161938}
1939
Howard Hinnant99968442011-11-29 18:15:501940template<class _Rp, class ..._ArgTypes>
1941template <typename _Tp>
1942const _Tp*
1943function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:161944{
1945 if (__f_ == 0)
Howard Hinnant99968442011-11-29 18:15:501946 return (const _Tp*)0;
1947 return (const _Tp*)__f_->target(typeid(_Tp));
Howard Hinnantbc8d3f92010-05-11 19:42:161948}
1949
Howard Hinnant324bb032010-08-22 00:02:431950#endif // _LIBCPP_NO_RTTI
Howard Hinnantd4444702010-08-11 17:04:311951
Howard Hinnant99968442011-11-29 18:15:501952template <class _Rp, class... _ArgTypes>
Howard Hinnantbc8d3f92010-05-11 19:42:161953inline _LIBCPP_INLINE_VISIBILITY
1954bool
Howard Hinnant99968442011-11-29 18:15:501955operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;}
Howard Hinnantbc8d3f92010-05-11 19:42:161956
Howard Hinnant99968442011-11-29 18:15:501957template <class _Rp, class... _ArgTypes>
Howard Hinnantbc8d3f92010-05-11 19:42:161958inline _LIBCPP_INLINE_VISIBILITY
1959bool
Howard Hinnant99968442011-11-29 18:15:501960operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;}
Howard Hinnantbc8d3f92010-05-11 19:42:161961
Howard Hinnant99968442011-11-29 18:15:501962template <class _Rp, class... _ArgTypes>
Howard Hinnantbc8d3f92010-05-11 19:42:161963inline _LIBCPP_INLINE_VISIBILITY
1964bool
Howard Hinnant99968442011-11-29 18:15:501965operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;}
Howard Hinnantbc8d3f92010-05-11 19:42:161966
Howard Hinnant99968442011-11-29 18:15:501967template <class _Rp, class... _ArgTypes>
Howard Hinnantbc8d3f92010-05-11 19:42:161968inline _LIBCPP_INLINE_VISIBILITY
1969bool
Howard Hinnant99968442011-11-29 18:15:501970operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;}
Howard Hinnantbc8d3f92010-05-11 19:42:161971
Howard Hinnant99968442011-11-29 18:15:501972template <class _Rp, class... _ArgTypes>
Howard Hinnantbc8d3f92010-05-11 19:42:161973inline _LIBCPP_INLINE_VISIBILITY
1974void
Howard Hinnant99968442011-11-29 18:15:501975swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:161976{return __x.swap(__y);}
1977
Eric Fiselierdb8c4fd2015-07-22 22:43:271978#else // _LIBCPP_HAS_NO_VARIADICS
1979
1980#include <__functional_03>
1981
1982#endif
Eric Fiselier45f63bc2015-07-22 04:14:381983
1984////////////////////////////////////////////////////////////////////////////////
1985// BIND
1986//==============================================================================
1987
Howard Hinnantbc8d3f92010-05-11 19:42:161988template<class _Tp> struct __is_bind_expression : public false_type {};
Eric Fiselierc3589a82017-01-04 23:56:001989template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_bind_expression
Howard Hinnantbc8d3f92010-05-11 19:42:161990 : public __is_bind_expression<typename remove_cv<_Tp>::type> {};
1991
Marshall Clow2fffe3a2016-09-22 00:23:151992#if _LIBCPP_STD_VER > 14
1993template <class _Tp>
1994constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;
1995#endif
1996
Howard Hinnantbc8d3f92010-05-11 19:42:161997template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {};
Eric Fiselierc3589a82017-01-04 23:56:001998template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_placeholder
Howard Hinnantbc8d3f92010-05-11 19:42:161999 : public __is_placeholder<typename remove_cv<_Tp>::type> {};
2000
Marshall Clow2fffe3a2016-09-22 00:23:152001#if _LIBCPP_STD_VER > 14
2002template <class _Tp>
2003constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value;
2004#endif
2005
Howard Hinnantbc8d3f92010-05-11 19:42:162006namespace placeholders
2007{
2008
Howard Hinnant99968442011-11-29 18:15:502009template <int _Np> struct __ph {};
Howard Hinnantbc8d3f92010-05-11 19:42:162010
Eric Fiselierabd892a2016-06-26 21:01:342011#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_BIND)
2012_LIBCPP_FUNC_VIS extern const __ph<1> _1;
2013_LIBCPP_FUNC_VIS extern const __ph<2> _2;
2014_LIBCPP_FUNC_VIS extern const __ph<3> _3;
2015_LIBCPP_FUNC_VIS extern const __ph<4> _4;
2016_LIBCPP_FUNC_VIS extern const __ph<5> _5;
2017_LIBCPP_FUNC_VIS extern const __ph<6> _6;
2018_LIBCPP_FUNC_VIS extern const __ph<7> _7;
2019_LIBCPP_FUNC_VIS extern const __ph<8> _8;
2020_LIBCPP_FUNC_VIS extern const __ph<9> _9;
2021_LIBCPP_FUNC_VIS extern const __ph<10> _10;
2022#else
2023constexpr __ph<1> _1{};
2024constexpr __ph<2> _2{};
2025constexpr __ph<3> _3{};
2026constexpr __ph<4> _4{};
2027constexpr __ph<5> _5{};
2028constexpr __ph<6> _6{};
2029constexpr __ph<7> _7{};
2030constexpr __ph<8> _8{};
2031constexpr __ph<9> _9{};
2032constexpr __ph<10> _10{};
2033#endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_BIND)
Howard Hinnantbc8d3f92010-05-11 19:42:162034
2035} // placeholders
2036
Howard Hinnant99968442011-11-29 18:15:502037template<int _Np>
2038struct __is_placeholder<placeholders::__ph<_Np> >
2039 : public integral_constant<int, _Np> {};
Howard Hinnantbc8d3f92010-05-11 19:42:162040
Eric Fiselier45f63bc2015-07-22 04:14:382041
2042#ifndef _LIBCPP_HAS_NO_VARIADICS
2043
Howard Hinnantbc8d3f92010-05-11 19:42:162044template <class _Tp, class _Uj>
2045inline _LIBCPP_INLINE_VISIBILITY
2046_Tp&
2047__mu(reference_wrapper<_Tp> __t, _Uj&)
2048{
2049 return __t.get();
2050}
2051
Howard Hinnantbc8d3f92010-05-11 19:42:162052template <class _Ti, class ..._Uj, size_t ..._Indx>
2053inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnant0148a832011-05-19 19:41:472054typename __invoke_of<_Ti&, _Uj...>::type
2055__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
Howard Hinnantbc8d3f92010-05-11 19:42:162056{
Marshall Clowba6dbf42014-06-24 00:46:192057 return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...);
Howard Hinnantbc8d3f92010-05-11 19:42:162058}
2059
2060template <class _Ti, class ..._Uj>
2061inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier60b3df42014-12-23 05:54:342062typename __lazy_enable_if
Howard Hinnantbc8d3f92010-05-11 19:42:162063<
2064 is_bind_expression<_Ti>::value,
Eric Fiselier60b3df42014-12-23 05:54:342065 __invoke_of<_Ti&, _Uj...>
Howard Hinnantbc8d3f92010-05-11 19:42:162066>::type
2067__mu(_Ti& __ti, tuple<_Uj...>& __uj)
2068{
2069 typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
2070 return __mu_expand(__ti, __uj, __indices());
2071}
2072
2073template <bool IsPh, class _Ti, class _Uj>
2074struct __mu_return2 {};
2075
2076template <class _Ti, class _Uj>
2077struct __mu_return2<true, _Ti, _Uj>
2078{
2079 typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
2080};
2081
2082template <class _Ti, class _Uj>
2083inline _LIBCPP_INLINE_VISIBILITY
2084typename enable_if
2085<
2086 0 < is_placeholder<_Ti>::value,
2087 typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
2088>::type
2089__mu(_Ti&, _Uj& __uj)
2090{
2091 const size_t _Indx = is_placeholder<_Ti>::value - 1;
Marshall Clowba6dbf42014-06-24 00:46:192092 return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj));
Howard Hinnantbc8d3f92010-05-11 19:42:162093}
2094
2095template <class _Ti, class _Uj>
2096inline _LIBCPP_INLINE_VISIBILITY
2097typename enable_if
2098<
2099 !is_bind_expression<_Ti>::value &&
2100 is_placeholder<_Ti>::value == 0 &&
2101 !__is_reference_wrapper<_Ti>::value,
2102 _Ti&
2103>::type
Howard Hinnantec3773c2011-12-01 20:21:042104__mu(_Ti& __ti, _Uj&)
Howard Hinnantbc8d3f92010-05-11 19:42:162105{
2106 return __ti;
2107}
2108
Howard Hinnantef542512011-05-22 15:07:432109template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh,
2110 class _TupleUj>
Howard Hinnantbc8d3f92010-05-11 19:42:162111struct ____mu_return;
2112
Howard Hinnantc05e9862013-06-30 19:48:152113template <bool _Invokable, class _Ti, class ..._Uj>
2114struct ____mu_return_invokable // false
2115{
2116 typedef __nat type;
2117};
2118
Howard Hinnantbc8d3f92010-05-11 19:42:162119template <class _Ti, class ..._Uj>
Howard Hinnantc05e9862013-06-30 19:48:152120struct ____mu_return_invokable<true, _Ti, _Uj...>
Howard Hinnantbc8d3f92010-05-11 19:42:162121{
Howard Hinnant0148a832011-05-19 19:41:472122 typedef typename __invoke_of<_Ti&, _Uj...>::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:162123};
2124
Howard Hinnantc05e9862013-06-30 19:48:152125template <class _Ti, class ..._Uj>
2126struct ____mu_return<_Ti, false, true, false, tuple<_Uj...> >
2127 : public ____mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...>
2128{
2129};
2130
Howard Hinnantbc8d3f92010-05-11 19:42:162131template <class _Ti, class _TupleUj>
Howard Hinnantef542512011-05-22 15:07:432132struct ____mu_return<_Ti, false, false, true, _TupleUj>
Howard Hinnantbc8d3f92010-05-11 19:42:162133{
2134 typedef typename tuple_element<is_placeholder<_Ti>::value - 1,
2135 _TupleUj>::type&& type;
2136};
2137
2138template <class _Ti, class _TupleUj>
Howard Hinnantef542512011-05-22 15:07:432139struct ____mu_return<_Ti, true, false, false, _TupleUj>
2140{
2141 typedef typename _Ti::type& type;
2142};
2143
2144template <class _Ti, class _TupleUj>
2145struct ____mu_return<_Ti, false, false, false, _TupleUj>
Howard Hinnantbc8d3f92010-05-11 19:42:162146{
2147 typedef _Ti& type;
2148};
2149
2150template <class _Ti, class _TupleUj>
2151struct __mu_return
2152 : public ____mu_return<_Ti,
Howard Hinnantef542512011-05-22 15:07:432153 __is_reference_wrapper<_Ti>::value,
Howard Hinnantbc8d3f92010-05-11 19:42:162154 is_bind_expression<_Ti>::value,
Howard Hinnant0560f782013-02-21 18:16:552155 0 < is_placeholder<_Ti>::value &&
2156 is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value,
Howard Hinnantbc8d3f92010-05-11 19:42:162157 _TupleUj>
2158{
2159};
2160
Howard Hinnant99968442011-11-29 18:15:502161template <class _Fp, class _BoundArgs, class _TupleUj>
Eric Fiselier5486fac2015-05-19 22:27:182162struct __is_valid_bind_return
Howard Hinnant0560f782013-02-21 18:16:552163{
2164 static const bool value = false;
2165};
2166
2167template <class _Fp, class ..._BoundArgs, class _TupleUj>
Eric Fiselier5486fac2015-05-19 22:27:182168struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
Howard Hinnant0560f782013-02-21 18:16:552169{
2170 static const bool value = __invokable<_Fp,
2171 typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
2172};
2173
2174template <class _Fp, class ..._BoundArgs, class _TupleUj>
Eric Fiselier5486fac2015-05-19 22:27:182175struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
Howard Hinnant0560f782013-02-21 18:16:552176{
2177 static const bool value = __invokable<_Fp,
2178 typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
2179};
2180
2181template <class _Fp, class _BoundArgs, class _TupleUj,
Eric Fiselier5486fac2015-05-19 22:27:182182 bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
Howard Hinnantbc8d3f92010-05-11 19:42:162183struct __bind_return;
2184
Howard Hinnant99968442011-11-29 18:15:502185template <class _Fp, class ..._BoundArgs, class _TupleUj>
Howard Hinnant0560f782013-02-21 18:16:552186struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true>
Howard Hinnantbc8d3f92010-05-11 19:42:162187{
Howard Hinnant0148a832011-05-19 19:41:472188 typedef typename __invoke_of
Howard Hinnantbc8d3f92010-05-11 19:42:162189 <
Howard Hinnant99968442011-11-29 18:15:502190 _Fp&,
Howard Hinnantbc8d3f92010-05-11 19:42:162191 typename __mu_return
2192 <
2193 _BoundArgs,
2194 _TupleUj
2195 >::type...
2196 >::type type;
2197};
2198
Howard Hinnant99968442011-11-29 18:15:502199template <class _Fp, class ..._BoundArgs, class _TupleUj>
Howard Hinnant0560f782013-02-21 18:16:552200struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true>
Howard Hinnantbc8d3f92010-05-11 19:42:162201{
Howard Hinnant0148a832011-05-19 19:41:472202 typedef typename __invoke_of
Howard Hinnantbc8d3f92010-05-11 19:42:162203 <
Howard Hinnant99968442011-11-29 18:15:502204 _Fp&,
Howard Hinnantbc8d3f92010-05-11 19:42:162205 typename __mu_return
2206 <
2207 const _BoundArgs,
2208 _TupleUj
2209 >::type...
2210 >::type type;
2211};
2212
Howard Hinnant99968442011-11-29 18:15:502213template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args>
Howard Hinnantbc8d3f92010-05-11 19:42:162214inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnant99968442011-11-29 18:15:502215typename __bind_return<_Fp, _BoundArgs, _Args>::type
2216__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
Howard Hinnantbc8d3f92010-05-11 19:42:162217 _Args&& __args)
2218{
Marshall Clowba6dbf42014-06-24 00:46:192219 return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...);
Howard Hinnantbc8d3f92010-05-11 19:42:162220}
2221
Howard Hinnant99968442011-11-29 18:15:502222template<class _Fp, class ..._BoundArgs>
Howard Hinnantbc8d3f92010-05-11 19:42:162223class __bind
Howard Hinnant99968442011-11-29 18:15:502224 : public __weak_result_type<typename decay<_Fp>::type>
Howard Hinnantbc8d3f92010-05-11 19:42:162225{
Howard Hinnant0560f782013-02-21 18:16:552226protected:
Howard Hinnant99968442011-11-29 18:15:502227 typedef typename decay<_Fp>::type _Fd;
Howard Hinnant0148a832011-05-19 19:41:472228 typedef tuple<typename decay<_BoundArgs>::type...> _Td;
Howard Hinnant0560f782013-02-21 18:16:552229private:
Howard Hinnant0148a832011-05-19 19:41:472230 _Fd __f_;
2231 _Td __bound_args_;
Howard Hinnantbc8d3f92010-05-11 19:42:162232
2233 typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
2234public:
Howard Hinnantd2da6d22012-05-04 17:21:022235 template <class _Gp, class ..._BA,
2236 class = typename enable_if
2237 <
Howard Hinnant099dec12013-07-01 00:01:512238 is_constructible<_Fd, _Gp>::value &&
2239 !is_same<typename remove_reference<_Gp>::type,
2240 __bind>::value
Howard Hinnantd2da6d22012-05-04 17:21:022241 >::type>
Howard Hinnant42a63a72010-09-21 22:55:272242 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant99968442011-11-29 18:15:502243 explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
2244 : __f_(_VSTD::forward<_Gp>(__f)),
Howard Hinnant0949eed2011-06-30 21:18:192245 __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}
Howard Hinnantbc8d3f92010-05-11 19:42:162246
2247 template <class ..._Args>
Howard Hinnant42a63a72010-09-21 22:55:272248 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant0148a832011-05-19 19:41:472249 typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
Howard Hinnantbc8d3f92010-05-11 19:42:162250 operator()(_Args&& ...__args)
2251 {
Howard Hinnant324bb032010-08-22 00:02:432252 return __apply_functor(__f_, __bound_args_, __indices(),
Howard Hinnant0949eed2011-06-30 21:18:192253 tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
Howard Hinnantbc8d3f92010-05-11 19:42:162254 }
2255
2256 template <class ..._Args>
Howard Hinnant42a63a72010-09-21 22:55:272257 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant0560f782013-02-21 18:16:552258 typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
Howard Hinnantbc8d3f92010-05-11 19:42:162259 operator()(_Args&& ...__args) const
2260 {
Howard Hinnant324bb032010-08-22 00:02:432261 return __apply_functor(__f_, __bound_args_, __indices(),
Howard Hinnant0949eed2011-06-30 21:18:192262 tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
Howard Hinnantbc8d3f92010-05-11 19:42:162263 }
2264};
2265
Howard Hinnant99968442011-11-29 18:15:502266template<class _Fp, class ..._BoundArgs>
2267struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:162268
Howard Hinnant99968442011-11-29 18:15:502269template<class _Rp, class _Fp, class ..._BoundArgs>
Howard Hinnantbc8d3f92010-05-11 19:42:162270class __bind_r
Howard Hinnant99968442011-11-29 18:15:502271 : public __bind<_Fp, _BoundArgs...>
Howard Hinnantbc8d3f92010-05-11 19:42:162272{
Howard Hinnant99968442011-11-29 18:15:502273 typedef __bind<_Fp, _BoundArgs...> base;
Howard Hinnant0560f782013-02-21 18:16:552274 typedef typename base::_Fd _Fd;
2275 typedef typename base::_Td _Td;
Howard Hinnantbc8d3f92010-05-11 19:42:162276public:
Howard Hinnant99968442011-11-29 18:15:502277 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:162278
Howard Hinnant90d77852011-07-02 18:22:362279
Howard Hinnant099dec12013-07-01 00:01:512280 template <class _Gp, class ..._BA,
2281 class = typename enable_if
2282 <
2283 is_constructible<_Fd, _Gp>::value &&
2284 !is_same<typename remove_reference<_Gp>::type,
2285 __bind_r>::value
2286 >::type>
Howard Hinnant42a63a72010-09-21 22:55:272287 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant99968442011-11-29 18:15:502288 explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
2289 : base(_VSTD::forward<_Gp>(__f),
Howard Hinnant0949eed2011-06-30 21:18:192290 _VSTD::forward<_BA>(__bound_args)...) {}
Howard Hinnantbc8d3f92010-05-11 19:42:162291
2292 template <class ..._Args>
Howard Hinnant42a63a72010-09-21 22:55:272293 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant0560f782013-02-21 18:16:552294 typename enable_if
2295 <
2296 is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
Eric Fiselierf301a112015-07-10 23:29:182297 result_type>::value || is_void<_Rp>::value,
Howard Hinnant0560f782013-02-21 18:16:552298 result_type
2299 >::type
Howard Hinnantbc8d3f92010-05-11 19:42:162300 operator()(_Args&& ...__args)
2301 {
Eric Fiselierf301a112015-07-10 23:29:182302 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
2303 return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...);
Howard Hinnantbc8d3f92010-05-11 19:42:162304 }
2305
2306 template <class ..._Args>
Howard Hinnant42a63a72010-09-21 22:55:272307 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant0560f782013-02-21 18:16:552308 typename enable_if
2309 <
2310 is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
Eric Fiselierf301a112015-07-10 23:29:182311 result_type>::value || is_void<_Rp>::value,
Howard Hinnant0560f782013-02-21 18:16:552312 result_type
2313 >::type
Howard Hinnantbc8d3f92010-05-11 19:42:162314 operator()(_Args&& ...__args) const
2315 {
Eric Fiselierf301a112015-07-10 23:29:182316 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
2317 return _Invoker::__call(static_cast<base const&>(*this), _VSTD::forward<_Args>(__args)...);
Howard Hinnantbc8d3f92010-05-11 19:42:162318 }
2319};
2320
Howard Hinnant99968442011-11-29 18:15:502321template<class _Rp, class _Fp, class ..._BoundArgs>
2322struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
Howard Hinnantbc8d3f92010-05-11 19:42:162323
Howard Hinnant99968442011-11-29 18:15:502324template<class _Fp, class ..._BoundArgs>
Howard Hinnantbc8d3f92010-05-11 19:42:162325inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnant99968442011-11-29 18:15:502326__bind<_Fp, _BoundArgs...>
2327bind(_Fp&& __f, _BoundArgs&&... __bound_args)
Howard Hinnantbc8d3f92010-05-11 19:42:162328{
Howard Hinnant99968442011-11-29 18:15:502329 typedef __bind<_Fp, _BoundArgs...> type;
2330 return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
Howard Hinnantbc8d3f92010-05-11 19:42:162331}
2332
Howard Hinnant99968442011-11-29 18:15:502333template<class _Rp, class _Fp, class ..._BoundArgs>
Howard Hinnantbc8d3f92010-05-11 19:42:162334inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnant99968442011-11-29 18:15:502335__bind_r<_Rp, _Fp, _BoundArgs...>
2336bind(_Fp&& __f, _BoundArgs&&... __bound_args)
Howard Hinnantbc8d3f92010-05-11 19:42:162337{
Howard Hinnant99968442011-11-29 18:15:502338 typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
2339 return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
Howard Hinnantbc8d3f92010-05-11 19:42:162340}
2341
2342#endif // _LIBCPP_HAS_NO_VARIADICS
2343
Eric Fiselier22dff532015-07-14 20:16:152344#if _LIBCPP_STD_VER > 14
Eric Fiselierc2308222016-06-02 01:25:412345
Eric Fiselier48aa2e12016-10-14 07:19:522346#define __cpp_lib_invoke 201411
2347
Eric Fiselier22dff532015-07-14 20:16:152348template <class _Fn, class ..._Args>
2349result_of_t<_Fn&&(_Args&&...)>
Eric Fiselierc2308222016-06-02 01:25:412350invoke(_Fn&& __f, _Args&&... __args)
2351 noexcept(noexcept(_VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...)))
2352{
2353 return _VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
Eric Fiselier22dff532015-07-14 20:16:152354}
Eric Fiselierc2308222016-06-02 01:25:412355
2356template <class _DecayFunc>
Eric Fiselierc3589a82017-01-04 23:56:002357class _LIBCPP_TEMPLATE_VIS __not_fn_imp {
Eric Fiselierc2308222016-06-02 01:25:412358 _DecayFunc __fd;
2359
2360public:
2361 __not_fn_imp() = delete;
2362
2363 template <class ..._Args>
2364 _LIBCPP_INLINE_VISIBILITY
Eric Fiselier715ca512016-06-27 00:40:412365 auto operator()(_Args&& ...__args) &
Eric Fiselierc2308222016-06-02 01:25:412366 noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)))
Marshall Clowc3f11982016-10-10 14:37:182367 -> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))
2368 { return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); }
Eric Fiselierc2308222016-06-02 01:25:412369
2370 template <class ..._Args>
2371 _LIBCPP_INLINE_VISIBILITY
Eric Fiselier715ca512016-06-27 00:40:412372 auto operator()(_Args&& ...__args) &&
2373 noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)))
Marshall Clowc3f11982016-10-10 14:37:182374 -> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))
2375 { return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); }
Eric Fiselier715ca512016-06-27 00:40:412376
2377 template <class ..._Args>
2378 _LIBCPP_INLINE_VISIBILITY
2379 auto operator()(_Args&& ...__args) const&
Eric Fiselierc2308222016-06-02 01:25:412380 noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)))
Marshall Clowc3f11982016-10-10 14:37:182381 -> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))
2382 { return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); }
Eric Fiselierc2308222016-06-02 01:25:412383
Eric Fiselier715ca512016-06-27 00:40:412384
2385 template <class ..._Args>
2386 _LIBCPP_INLINE_VISIBILITY
2387 auto operator()(_Args&& ...__args) const&&
2388 noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)))
Marshall Clowc3f11982016-10-10 14:37:182389 -> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))
2390 { return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); }
Eric Fiselier715ca512016-06-27 00:40:412391
Eric Fiselierc2308222016-06-02 01:25:412392private:
2393 template <class _RawFunc,
2394 class = enable_if_t<!is_same<decay_t<_RawFunc>, __not_fn_imp>::value>>
2395 _LIBCPP_INLINE_VISIBILITY
2396 explicit __not_fn_imp(_RawFunc&& __rf)
2397 : __fd(_VSTD::forward<_RawFunc>(__rf)) {}
2398
2399 template <class _RawFunc>
2400 friend inline _LIBCPP_INLINE_VISIBILITY
2401 __not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&&);
2402};
2403
2404template <class _RawFunc>
2405inline _LIBCPP_INLINE_VISIBILITY
2406__not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&& __fn) {
2407 return __not_fn_imp<decay_t<_RawFunc>>(_VSTD::forward<_RawFunc>(__fn));
2408}
2409
Eric Fiselier22dff532015-07-14 20:16:152410#endif
2411
Howard Hinnant21aefc32010-06-03 16:42:572412// struct hash<T*> in <memory>
Howard Hinnantbc8d3f92010-05-11 19:42:162413
Howard Hinnantbc8d3f92010-05-11 19:42:162414_LIBCPP_END_NAMESPACE_STD
2415
2416#endif // _LIBCPP_FUNCTIONAL