functional revision 289082
1227825Stheraven// -*- C++ -*- 2227825Stheraven//===------------------------ functional ----------------------------------===// 3227825Stheraven// 4227825Stheraven// The LLVM Compiler Infrastructure 5227825Stheraven// 6227825Stheraven// This file is dual licensed under the MIT and the University of Illinois Open 7227825Stheraven// Source Licenses. See LICENSE.TXT for details. 8227825Stheraven// 9227825Stheraven//===----------------------------------------------------------------------===// 10227825Stheraven 11227825Stheraven#ifndef _LIBCPP_FUNCTIONAL 12227825Stheraven#define _LIBCPP_FUNCTIONAL 13227825Stheraven 14227825Stheraven/* 15227825Stheraven functional synopsis 16227825Stheraven 17227825Stheravennamespace std 18227825Stheraven{ 19227825Stheraven 20227825Stheraventemplate <class Arg, class Result> 21227825Stheravenstruct unary_function 22227825Stheraven{ 23227825Stheraven typedef Arg argument_type; 24227825Stheraven typedef Result result_type; 25227825Stheraven}; 26227825Stheraven 27227825Stheraventemplate <class Arg1, class Arg2, class Result> 28227825Stheravenstruct binary_function 29227825Stheraven{ 30227825Stheraven typedef Arg1 first_argument_type; 31227825Stheraven typedef Arg2 second_argument_type; 32227825Stheraven typedef Result result_type; 33227825Stheraven}; 34227825Stheraven 35227825Stheraventemplate <class T> 36227825Stheravenclass reference_wrapper 37227825Stheraven : public unary_function<T1, R> // if wrapping a unary functor 38227825Stheraven : public binary_function<T1, T2, R> // if wraping a binary functor 39227825Stheraven{ 40227825Stheravenpublic: 41227825Stheraven // types 42227825Stheraven typedef T type; 43227825Stheraven typedef see below result_type; // Not always defined 44227825Stheraven 45227825Stheraven // construct/copy/destroy 46227825Stheraven reference_wrapper(T&) noexcept; 47227825Stheraven reference_wrapper(T&&) = delete; // do not bind to temps 48227825Stheraven reference_wrapper(const reference_wrapper<T>& x) noexcept; 49227825Stheraven 50227825Stheraven // assignment 51227825Stheraven reference_wrapper& operator=(const reference_wrapper<T>& x) noexcept; 52227825Stheraven 53227825Stheraven // access 54227825Stheraven operator T& () const noexcept; 55227825Stheraven T& get() const noexcept; 56227825Stheraven 57227825Stheraven // invoke 58227825Stheraven template <class... ArgTypes> 59261272Sdim typename result_of<T&(ArgTypes&&...)>::type 60227825Stheraven operator() (ArgTypes&&...) const; 61227825Stheraven}; 62227825Stheraven 63227825Stheraventemplate <class T> reference_wrapper<T> ref(T& t) noexcept; 64227825Stheraventemplate <class T> void ref(const T&& t) = delete; 65227825Stheraventemplate <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept; 66227825Stheraven 67227825Stheraventemplate <class T> reference_wrapper<const T> cref(const T& t) noexcept; 68227825Stheraventemplate <class T> void cref(const T&& t) = delete; 69227825Stheraventemplate <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept; 70227825Stheraven 71261272Sdimtemplate <class T> // <class T=void> in C++14 72227825Stheravenstruct plus : binary_function<T, T, T> 73227825Stheraven{ 74227825Stheraven T operator()(const T& x, const T& y) const; 75227825Stheraven}; 76227825Stheraven 77261272Sdimtemplate <class T> // <class T=void> in C++14 78227825Stheravenstruct minus : binary_function<T, T, T> 79227825Stheraven{ 80227825Stheraven T operator()(const T& x, const T& y) const; 81227825Stheraven}; 82227825Stheraven 83261272Sdimtemplate <class T> // <class T=void> in C++14 84227825Stheravenstruct multiplies : binary_function<T, T, T> 85227825Stheraven{ 86227825Stheraven T operator()(const T& x, const T& y) const; 87227825Stheraven}; 88227825Stheraven 89261272Sdimtemplate <class T> // <class T=void> in C++14 90227825Stheravenstruct divides : binary_function<T, T, T> 91227825Stheraven{ 92227825Stheraven T operator()(const T& x, const T& y) const; 93227825Stheraven}; 94227825Stheraven 95261272Sdimtemplate <class T> // <class T=void> in C++14 96227825Stheravenstruct modulus : binary_function<T, T, T> 97227825Stheraven{ 98227825Stheraven T operator()(const T& x, const T& y) const; 99227825Stheraven}; 100227825Stheraven 101261272Sdimtemplate <class T> // <class T=void> in C++14 102227825Stheravenstruct negate : unary_function<T, T> 103227825Stheraven{ 104227825Stheraven T operator()(const T& x) const; 105227825Stheraven}; 106227825Stheraven 107261272Sdimtemplate <class T> // <class T=void> in C++14 108227825Stheravenstruct equal_to : binary_function<T, T, bool> 109227825Stheraven{ 110227825Stheraven bool operator()(const T& x, const T& y) const; 111227825Stheraven}; 112227825Stheraven 113261272Sdimtemplate <class T> // <class T=void> in C++14 114227825Stheravenstruct not_equal_to : binary_function<T, T, bool> 115227825Stheraven{ 116227825Stheraven bool operator()(const T& x, const T& y) const; 117227825Stheraven}; 118227825Stheraven 119261272Sdimtemplate <class T> // <class T=void> in C++14 120227825Stheravenstruct greater : binary_function<T, T, bool> 121227825Stheraven{ 122227825Stheraven bool operator()(const T& x, const T& y) const; 123227825Stheraven}; 124227825Stheraven 125261272Sdimtemplate <class T> // <class T=void> in C++14 126227825Stheravenstruct less : binary_function<T, T, bool> 127227825Stheraven{ 128227825Stheraven bool operator()(const T& x, const T& y) const; 129227825Stheraven}; 130227825Stheraven 131261272Sdimtemplate <class T> // <class T=void> in C++14 132227825Stheravenstruct greater_equal : binary_function<T, T, bool> 133227825Stheraven{ 134227825Stheraven bool operator()(const T& x, const T& y) const; 135227825Stheraven}; 136227825Stheraven 137261272Sdimtemplate <class T> // <class T=void> in C++14 138227825Stheravenstruct less_equal : binary_function<T, T, bool> 139227825Stheraven{ 140227825Stheraven bool operator()(const T& x, const T& y) const; 141227825Stheraven}; 142227825Stheraven 143261272Sdimtemplate <class T> // <class T=void> in C++14 144227825Stheravenstruct logical_and : binary_function<T, T, bool> 145227825Stheraven{ 146227825Stheraven bool operator()(const T& x, const T& y) const; 147227825Stheraven}; 148227825Stheraven 149261272Sdimtemplate <class T> // <class T=void> in C++14 150227825Stheravenstruct logical_or : binary_function<T, T, bool> 151227825Stheraven{ 152227825Stheraven bool operator()(const T& x, const T& y) const; 153227825Stheraven}; 154227825Stheraven 155261272Sdimtemplate <class T> // <class T=void> in C++14 156227825Stheravenstruct logical_not : unary_function<T, bool> 157227825Stheraven{ 158227825Stheraven bool operator()(const T& x) const; 159227825Stheraven}; 160227825Stheraven 161261272Sdimtemplate <class T> // <class T=void> in C++14 162261272Sdimstruct bit_and : unary_function<T, bool> 163261272Sdim{ 164261272Sdim bool operator()(const T& x, const T& y) const; 165261272Sdim}; 166261272Sdim 167261272Sdimtemplate <class T> // <class T=void> in C++14 168261272Sdimstruct bit_or : unary_function<T, bool> 169261272Sdim{ 170261272Sdim bool operator()(const T& x, const T& y) const; 171261272Sdim}; 172261272Sdim 173261272Sdimtemplate <class T> // <class T=void> in C++14 174261272Sdimstruct bit_xor : unary_function<T, bool> 175261272Sdim{ 176261272Sdim bool operator()(const T& x, const T& y) const; 177261272Sdim}; 178261272Sdim 179261272Sdimtemplate <class T=void> // C++14 180261272Sdimstruct bit_xor : unary_function<T, bool> 181261272Sdim{ 182261272Sdim bool operator()(const T& x) const; 183261272Sdim}; 184261272Sdim 185227825Stheraventemplate <class Predicate> 186227825Stheravenclass unary_negate 187227825Stheraven : public unary_function<typename Predicate::argument_type, bool> 188227825Stheraven{ 189227825Stheravenpublic: 190227825Stheraven explicit unary_negate(const Predicate& pred); 191227825Stheraven bool operator()(const typename Predicate::argument_type& x) const; 192227825Stheraven}; 193227825Stheraven 194227825Stheraventemplate <class Predicate> unary_negate<Predicate> not1(const Predicate& pred); 195227825Stheraven 196227825Stheraventemplate <class Predicate> 197227825Stheravenclass binary_negate 198227825Stheraven : public binary_function<typename Predicate::first_argument_type, 199227825Stheraven typename Predicate::second_argument_type, 200227825Stheraven bool> 201227825Stheraven{ 202227825Stheravenpublic: 203227825Stheraven explicit binary_negate(const Predicate& pred); 204227825Stheraven bool operator()(const typename Predicate::first_argument_type& x, 205227825Stheraven const typename Predicate::second_argument_type& y) const; 206227825Stheraven}; 207227825Stheraven 208227825Stheraventemplate <class Predicate> binary_negate<Predicate> not2(const Predicate& pred); 209227825Stheraven 210227825Stheraventemplate<class T> struct is_bind_expression; 211227825Stheraventemplate<class T> struct is_placeholder; 212227825Stheraven 213227825Stheraventemplate<class Fn, class... BoundArgs> 214227825Stheraven unspecified bind(Fn&&, BoundArgs&&...); 215227825Stheraventemplate<class R, class Fn, class... BoundArgs> 216227825Stheraven unspecified bind(Fn&&, BoundArgs&&...); 217227825Stheraven 218227825Stheravennamespace placeholders { 219227825Stheraven // M is the implementation-defined number of placeholders 220227825Stheraven extern unspecified _1; 221227825Stheraven extern unspecified _2; 222227825Stheraven . 223227825Stheraven . 224227825Stheraven . 225232924Stheraven extern unspecified _Mp; 226227825Stheraven} 227227825Stheraven 228227825Stheraventemplate <class Operation> 229227825Stheravenclass binder1st 230227825Stheraven : public unary_function<typename Operation::second_argument_type, 231227825Stheraven typename Operation::result_type> 232227825Stheraven{ 233227825Stheravenprotected: 234227825Stheraven Operation op; 235227825Stheraven typename Operation::first_argument_type value; 236227825Stheravenpublic: 237227825Stheraven binder1st(const Operation& x, const typename Operation::first_argument_type y); 238227825Stheraven typename Operation::result_type operator()( typename Operation::second_argument_type& x) const; 239227825Stheraven typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const; 240227825Stheraven}; 241227825Stheraven 242227825Stheraventemplate <class Operation, class T> 243227825Stheravenbinder1st<Operation> bind1st(const Operation& op, const T& x); 244227825Stheraven 245227825Stheraventemplate <class Operation> 246227825Stheravenclass binder2nd 247227825Stheraven : public unary_function<typename Operation::first_argument_type, 248227825Stheraven typename Operation::result_type> 249227825Stheraven{ 250227825Stheravenprotected: 251227825Stheraven Operation op; 252227825Stheraven typename Operation::second_argument_type value; 253227825Stheravenpublic: 254227825Stheraven binder2nd(const Operation& x, const typename Operation::second_argument_type y); 255227825Stheraven typename Operation::result_type operator()( typename Operation::first_argument_type& x) const; 256227825Stheraven typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const; 257227825Stheraven}; 258227825Stheraven 259227825Stheraventemplate <class Operation, class T> 260227825Stheravenbinder2nd<Operation> bind2nd(const Operation& op, const T& x); 261227825Stheraven 262227825Stheraventemplate <class Arg, class Result> 263227825Stheravenclass pointer_to_unary_function : public unary_function<Arg, Result> 264227825Stheraven{ 265227825Stheravenpublic: 266227825Stheraven explicit pointer_to_unary_function(Result (*f)(Arg)); 267227825Stheraven Result operator()(Arg x) const; 268227825Stheraven}; 269227825Stheraven 270227825Stheraventemplate <class Arg, class Result> 271227825Stheravenpointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg)); 272227825Stheraven 273227825Stheraventemplate <class Arg1, class Arg2, class Result> 274227825Stheravenclass pointer_to_binary_function : public binary_function<Arg1, Arg2, Result> 275227825Stheraven{ 276227825Stheravenpublic: 277227825Stheraven explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)); 278227825Stheraven Result operator()(Arg1 x, Arg2 y) const; 279227825Stheraven}; 280227825Stheraven 281227825Stheraventemplate <class Arg1, class Arg2, class Result> 282227825Stheravenpointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2)); 283227825Stheraven 284227825Stheraventemplate<class S, class T> 285227825Stheravenclass mem_fun_t : public unary_function<T*, S> 286227825Stheraven{ 287227825Stheravenpublic: 288227825Stheraven explicit mem_fun_t(S (T::*p)()); 289227825Stheraven S operator()(T* p) const; 290227825Stheraven}; 291227825Stheraven 292227825Stheraventemplate<class S, class T, class A> 293227825Stheravenclass mem_fun1_t : public binary_function<T*, A, S> 294227825Stheraven{ 295227825Stheravenpublic: 296227825Stheraven explicit mem_fun1_t(S (T::*p)(A)); 297227825Stheraven S operator()(T* p, A x) const; 298227825Stheraven}; 299227825Stheraven 300227825Stheraventemplate<class S, class T> mem_fun_t<S,T> mem_fun(S (T::*f)()); 301227825Stheraventemplate<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A)); 302227825Stheraven 303227825Stheraventemplate<class S, class T> 304227825Stheravenclass mem_fun_ref_t : public unary_function<T, S> 305227825Stheraven{ 306227825Stheravenpublic: 307227825Stheraven explicit mem_fun_ref_t(S (T::*p)()); 308227825Stheraven S operator()(T& p) const; 309227825Stheraven}; 310227825Stheraven 311227825Stheraventemplate<class S, class T, class A> 312227825Stheravenclass mem_fun1_ref_t : public binary_function<T, A, S> 313227825Stheraven{ 314227825Stheravenpublic: 315227825Stheraven explicit mem_fun1_ref_t(S (T::*p)(A)); 316227825Stheraven S operator()(T& p, A x) const; 317227825Stheraven}; 318227825Stheraven 319227825Stheraventemplate<class S, class T> mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)()); 320227825Stheraventemplate<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A)); 321227825Stheraven 322227825Stheraventemplate <class S, class T> 323227825Stheravenclass const_mem_fun_t : public unary_function<const T*, S> 324227825Stheraven{ 325227825Stheravenpublic: 326227825Stheraven explicit const_mem_fun_t(S (T::*p)() const); 327227825Stheraven S operator()(const T* p) const; 328227825Stheraven}; 329227825Stheraven 330227825Stheraventemplate <class S, class T, class A> 331227825Stheravenclass const_mem_fun1_t : public binary_function<const T*, A, S> 332227825Stheraven{ 333227825Stheravenpublic: 334227825Stheraven explicit const_mem_fun1_t(S (T::*p)(A) const); 335227825Stheraven S operator()(const T* p, A x) const; 336227825Stheraven}; 337227825Stheraven 338227825Stheraventemplate <class S, class T> const_mem_fun_t<S,T> mem_fun(S (T::*f)() const); 339227825Stheraventemplate <class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const); 340227825Stheraven 341227825Stheraventemplate <class S, class T> 342227825Stheravenclass const_mem_fun_ref_t : public unary_function<T, S> 343227825Stheraven{ 344227825Stheravenpublic: 345227825Stheraven explicit const_mem_fun_ref_t(S (T::*p)() const); 346227825Stheraven S operator()(const T& p) const; 347227825Stheraven}; 348227825Stheraven 349227825Stheraventemplate <class S, class T, class A> 350227825Stheravenclass const_mem_fun1_ref_t : public binary_function<T, A, S> 351227825Stheraven{ 352227825Stheravenpublic: 353227825Stheraven explicit const_mem_fun1_ref_t(S (T::*p)(A) const); 354227825Stheraven S operator()(const T& p, A x) const; 355227825Stheraven}; 356227825Stheraven 357227825Stheraventemplate <class S, class T> const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const); 358227825Stheraventemplate <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const); 359227825Stheraven 360227825Stheraventemplate<class R, class T> unspecified mem_fn(R T::*); 361227825Stheraven 362227825Stheravenclass bad_function_call 363227825Stheraven : public exception 364227825Stheraven{ 365227825Stheraven}; 366227825Stheraven 367227825Stheraventemplate<class> class function; // undefined 368227825Stheraven 369227825Stheraventemplate<class R, class... ArgTypes> 370227825Stheravenclass function<R(ArgTypes...)> 371227825Stheraven : public unary_function<T1, R> // iff sizeof...(ArgTypes) == 1 and 372227825Stheraven // ArgTypes contains T1 373227825Stheraven : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and 374227825Stheraven // ArgTypes contains T1 and T2 375227825Stheraven{ 376227825Stheravenpublic: 377227825Stheraven typedef R result_type; 378227825Stheraven 379227825Stheraven // construct/copy/destroy: 380227825Stheraven function() noexcept; 381227825Stheraven function(nullptr_t) noexcept; 382227825Stheraven function(const function&); 383227825Stheraven function(function&&) noexcept; 384227825Stheraven template<class F> 385227825Stheraven function(F); 386227825Stheraven template<Allocator Alloc> 387227825Stheraven function(allocator_arg_t, const Alloc&) noexcept; 388227825Stheraven template<Allocator Alloc> 389227825Stheraven function(allocator_arg_t, const Alloc&, nullptr_t) noexcept; 390227825Stheraven template<Allocator Alloc> 391227825Stheraven function(allocator_arg_t, const Alloc&, const function&); 392227825Stheraven template<Allocator Alloc> 393227825Stheraven function(allocator_arg_t, const Alloc&, function&&); 394227825Stheraven template<class F, Allocator Alloc> 395227825Stheraven function(allocator_arg_t, const Alloc&, F); 396227825Stheraven 397227825Stheraven function& operator=(const function&); 398227825Stheraven function& operator=(function&&) noexcept; 399227825Stheraven function& operator=(nullptr_t) noexcept; 400227825Stheraven template<class F> 401227825Stheraven function& operator=(F&&); 402227825Stheraven template<class F> 403227825Stheraven function& operator=(reference_wrapper<F>) noexcept; 404227825Stheraven 405227825Stheraven ~function(); 406227825Stheraven 407227825Stheraven // function modifiers: 408227825Stheraven void swap(function&) noexcept; 409227825Stheraven template<class F, class Alloc> 410227825Stheraven void assign(F&&, const Alloc&); 411227825Stheraven 412227825Stheraven // function capacity: 413227825Stheraven explicit operator bool() const noexcept; 414227825Stheraven 415227825Stheraven // function invocation: 416227825Stheraven R operator()(ArgTypes...) const; 417227825Stheraven 418227825Stheraven // function target access: 419227825Stheraven const std::type_info& target_type() const noexcept; 420227825Stheraven template <typename T> T* target() noexcept; 421227825Stheraven template <typename T> const T* target() const noexcept; 422227825Stheraven}; 423227825Stheraven 424227825Stheraven// Null pointer comparisons: 425227825Stheraventemplate <class R, class ... ArgTypes> 426227825Stheraven bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept; 427227825Stheraven 428227825Stheraventemplate <class R, class ... ArgTypes> 429227825Stheraven bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept; 430227825Stheraven 431227825Stheraventemplate <class R, class ... ArgTypes> 432227825Stheraven bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept; 433227825Stheraven 434227825Stheraventemplate <class R, class ... ArgTypes> 435227825Stheraven bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept; 436227825Stheraven 437227825Stheraven// specialized algorithms: 438227825Stheraventemplate <class R, class ... ArgTypes> 439227825Stheraven void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept; 440227825Stheraven 441227825Stheraventemplate <class T> struct hash; 442227825Stheraven 443227825Stheraventemplate <> struct hash<bool>; 444227825Stheraventemplate <> struct hash<char>; 445227825Stheraventemplate <> struct hash<signed char>; 446227825Stheraventemplate <> struct hash<unsigned char>; 447227825Stheraventemplate <> struct hash<char16_t>; 448227825Stheraventemplate <> struct hash<char32_t>; 449227825Stheraventemplate <> struct hash<wchar_t>; 450227825Stheraventemplate <> struct hash<short>; 451227825Stheraventemplate <> struct hash<unsigned short>; 452227825Stheraventemplate <> struct hash<int>; 453227825Stheraventemplate <> struct hash<unsigned int>; 454227825Stheraventemplate <> struct hash<long>; 455227825Stheraventemplate <> struct hash<long long>; 456227825Stheraventemplate <> struct hash<unsigned long>; 457227825Stheraventemplate <> struct hash<unsigned long long>; 458227825Stheraven 459227825Stheraventemplate <> struct hash<float>; 460227825Stheraventemplate <> struct hash<double>; 461227825Stheraventemplate <> struct hash<long double>; 462227825Stheraven 463227825Stheraventemplate<class T> struct hash<T*>; 464227825Stheraven 465227825Stheraven} // std 466227825Stheraven 467227825StheravenPOLICY: For non-variadic implementations, the number of arguments is limited 468227825Stheraven to 3. It is hoped that the need for non-variadic implementations 469227825Stheraven will be minimal. 470227825Stheraven 471227825Stheraven*/ 472227825Stheraven 473227825Stheraven#include <__config> 474227825Stheraven#include <type_traits> 475227825Stheraven#include <typeinfo> 476227825Stheraven#include <exception> 477227825Stheraven#include <memory> 478227825Stheraven#include <tuple> 479227825Stheraven 480227825Stheraven#include <__functional_base> 481227825Stheraven 482227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 483227825Stheraven#pragma GCC system_header 484227825Stheraven#endif 485227825Stheraven 486227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD 487227825Stheraven 488261272Sdim#if _LIBCPP_STD_VER > 11 489261272Sdimtemplate <class _Tp = void> 490261272Sdim#else 491227825Stheraventemplate <class _Tp> 492261272Sdim#endif 493261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY plus : binary_function<_Tp, _Tp, _Tp> 494227825Stheraven{ 495261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 496261272Sdim _Tp operator()(const _Tp& __x, const _Tp& __y) const 497227825Stheraven {return __x + __y;} 498227825Stheraven}; 499227825Stheraven 500261272Sdim#if _LIBCPP_STD_VER > 11 501261272Sdimtemplate <> 502261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY plus<void> 503261272Sdim{ 504261272Sdim template <class _T1, class _T2> 505261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 506261272Sdim auto operator()(_T1&& __t, _T2&& __u) const 507288943Sdim _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))) 508288943Sdim -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)) 509288943Sdim { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } 510261272Sdim typedef void is_transparent; 511261272Sdim}; 512261272Sdim#endif 513261272Sdim 514261272Sdim 515261272Sdim#if _LIBCPP_STD_VER > 11 516261272Sdimtemplate <class _Tp = void> 517261272Sdim#else 518227825Stheraventemplate <class _Tp> 519261272Sdim#endif 520261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY minus : binary_function<_Tp, _Tp, _Tp> 521227825Stheraven{ 522261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 523261272Sdim _Tp operator()(const _Tp& __x, const _Tp& __y) const 524227825Stheraven {return __x - __y;} 525227825Stheraven}; 526227825Stheraven 527261272Sdim#if _LIBCPP_STD_VER > 11 528261272Sdimtemplate <> 529261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY minus<void> 530261272Sdim{ 531261272Sdim template <class _T1, class _T2> 532261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 533261272Sdim auto operator()(_T1&& __t, _T2&& __u) const 534288943Sdim _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))) 535288943Sdim -> decltype (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)) 536288943Sdim { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } 537261272Sdim typedef void is_transparent; 538261272Sdim}; 539261272Sdim#endif 540261272Sdim 541261272Sdim 542261272Sdim#if _LIBCPP_STD_VER > 11 543261272Sdimtemplate <class _Tp = void> 544261272Sdim#else 545227825Stheraventemplate <class _Tp> 546261272Sdim#endif 547261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY multiplies : binary_function<_Tp, _Tp, _Tp> 548227825Stheraven{ 549261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 550261272Sdim _Tp operator()(const _Tp& __x, const _Tp& __y) const 551227825Stheraven {return __x * __y;} 552227825Stheraven}; 553227825Stheraven 554261272Sdim#if _LIBCPP_STD_VER > 11 555261272Sdimtemplate <> 556261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY multiplies<void> 557261272Sdim{ 558261272Sdim template <class _T1, class _T2> 559261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 560261272Sdim auto operator()(_T1&& __t, _T2&& __u) const 561288943Sdim _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))) 562288943Sdim -> decltype (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)) 563288943Sdim { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } 564261272Sdim typedef void is_transparent; 565261272Sdim}; 566261272Sdim#endif 567261272Sdim 568261272Sdim 569261272Sdim#if _LIBCPP_STD_VER > 11 570261272Sdimtemplate <class _Tp = void> 571261272Sdim#else 572227825Stheraventemplate <class _Tp> 573261272Sdim#endif 574261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY divides : binary_function<_Tp, _Tp, _Tp> 575227825Stheraven{ 576261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 577261272Sdim _Tp operator()(const _Tp& __x, const _Tp& __y) const 578227825Stheraven {return __x / __y;} 579227825Stheraven}; 580227825Stheraven 581261272Sdim#if _LIBCPP_STD_VER > 11 582261272Sdimtemplate <> 583261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY divides<void> 584261272Sdim{ 585261272Sdim template <class _T1, class _T2> 586261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 587261272Sdim auto operator()(_T1&& __t, _T2&& __u) const 588288943Sdim _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))) 589288943Sdim -> decltype (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)) 590288943Sdim { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } 591261272Sdim typedef void is_transparent; 592261272Sdim}; 593261272Sdim#endif 594261272Sdim 595261272Sdim 596261272Sdim#if _LIBCPP_STD_VER > 11 597261272Sdimtemplate <class _Tp = void> 598261272Sdim#else 599227825Stheraventemplate <class _Tp> 600261272Sdim#endif 601261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY modulus : binary_function<_Tp, _Tp, _Tp> 602227825Stheraven{ 603261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 604261272Sdim _Tp operator()(const _Tp& __x, const _Tp& __y) const 605227825Stheraven {return __x % __y;} 606227825Stheraven}; 607227825Stheraven 608261272Sdim#if _LIBCPP_STD_VER > 11 609261272Sdimtemplate <> 610261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY modulus<void> 611261272Sdim{ 612261272Sdim template <class _T1, class _T2> 613261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 614261272Sdim auto operator()(_T1&& __t, _T2&& __u) const 615288943Sdim _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))) 616288943Sdim -> decltype (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)) 617288943Sdim { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } 618261272Sdim typedef void is_transparent; 619261272Sdim}; 620261272Sdim#endif 621261272Sdim 622261272Sdim 623261272Sdim#if _LIBCPP_STD_VER > 11 624261272Sdimtemplate <class _Tp = void> 625261272Sdim#else 626227825Stheraventemplate <class _Tp> 627261272Sdim#endif 628261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY negate : unary_function<_Tp, _Tp> 629227825Stheraven{ 630261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 631261272Sdim _Tp operator()(const _Tp& __x) const 632227825Stheraven {return -__x;} 633227825Stheraven}; 634227825Stheraven 635261272Sdim#if _LIBCPP_STD_VER > 11 636261272Sdimtemplate <> 637261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY negate<void> 638261272Sdim{ 639261272Sdim template <class _Tp> 640261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 641261272Sdim auto operator()(_Tp&& __x) const 642288943Sdim _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x))) 643288943Sdim -> decltype (- _VSTD::forward<_Tp>(__x)) 644288943Sdim { return - _VSTD::forward<_Tp>(__x); } 645261272Sdim typedef void is_transparent; 646261272Sdim}; 647261272Sdim#endif 648261272Sdim 649261272Sdim 650261272Sdim#if _LIBCPP_STD_VER > 11 651261272Sdimtemplate <class _Tp = void> 652261272Sdim#else 653227825Stheraventemplate <class _Tp> 654261272Sdim#endif 655261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY equal_to : binary_function<_Tp, _Tp, bool> 656227825Stheraven{ 657261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 658261272Sdim bool operator()(const _Tp& __x, const _Tp& __y) const 659227825Stheraven {return __x == __y;} 660227825Stheraven}; 661227825Stheraven 662261272Sdim#if _LIBCPP_STD_VER > 11 663261272Sdimtemplate <> 664261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY equal_to<void> 665261272Sdim{ 666261272Sdim template <class _T1, class _T2> 667261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 668261272Sdim auto operator()(_T1&& __t, _T2&& __u) const 669288943Sdim _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))) 670288943Sdim -> decltype (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)) 671288943Sdim { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } 672261272Sdim typedef void is_transparent; 673261272Sdim}; 674261272Sdim#endif 675261272Sdim 676261272Sdim 677261272Sdim#if _LIBCPP_STD_VER > 11 678261272Sdimtemplate <class _Tp = void> 679261272Sdim#else 680227825Stheraventemplate <class _Tp> 681261272Sdim#endif 682261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY not_equal_to : binary_function<_Tp, _Tp, bool> 683227825Stheraven{ 684261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 685261272Sdim bool operator()(const _Tp& __x, const _Tp& __y) const 686227825Stheraven {return __x != __y;} 687227825Stheraven}; 688227825Stheraven 689261272Sdim#if _LIBCPP_STD_VER > 11 690261272Sdimtemplate <> 691261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY not_equal_to<void> 692261272Sdim{ 693261272Sdim template <class _T1, class _T2> 694261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 695261272Sdim auto operator()(_T1&& __t, _T2&& __u) const 696288943Sdim _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))) 697288943Sdim -> decltype (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)) 698288943Sdim { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } 699261272Sdim typedef void is_transparent; 700261272Sdim}; 701261272Sdim#endif 702261272Sdim 703261272Sdim 704261272Sdim#if _LIBCPP_STD_VER > 11 705261272Sdimtemplate <class _Tp = void> 706261272Sdim#else 707227825Stheraventemplate <class _Tp> 708261272Sdim#endif 709261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY greater : binary_function<_Tp, _Tp, bool> 710227825Stheraven{ 711261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 712261272Sdim bool operator()(const _Tp& __x, const _Tp& __y) const 713227825Stheraven {return __x > __y;} 714227825Stheraven}; 715227825Stheraven 716261272Sdim#if _LIBCPP_STD_VER > 11 717261272Sdimtemplate <> 718261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY greater<void> 719261272Sdim{ 720261272Sdim template <class _T1, class _T2> 721261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 722261272Sdim auto operator()(_T1&& __t, _T2&& __u) const 723288943Sdim _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))) 724288943Sdim -> decltype (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)) 725288943Sdim { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } 726261272Sdim typedef void is_transparent; 727261272Sdim}; 728261272Sdim#endif 729261272Sdim 730261272Sdim 731232924Stheraven// less in <__functional_base> 732227825Stheraven 733261272Sdim#if _LIBCPP_STD_VER > 11 734261272Sdimtemplate <class _Tp = void> 735261272Sdim#else 736227825Stheraventemplate <class _Tp> 737261272Sdim#endif 738261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY greater_equal : binary_function<_Tp, _Tp, bool> 739227825Stheraven{ 740261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 741261272Sdim bool operator()(const _Tp& __x, const _Tp& __y) const 742227825Stheraven {return __x >= __y;} 743227825Stheraven}; 744227825Stheraven 745261272Sdim#if _LIBCPP_STD_VER > 11 746261272Sdimtemplate <> 747261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY greater_equal<void> 748261272Sdim{ 749261272Sdim template <class _T1, class _T2> 750261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 751261272Sdim auto operator()(_T1&& __t, _T2&& __u) const 752288943Sdim _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))) 753288943Sdim -> decltype (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)) 754288943Sdim { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } 755261272Sdim typedef void is_transparent; 756261272Sdim}; 757261272Sdim#endif 758261272Sdim 759261272Sdim 760261272Sdim#if _LIBCPP_STD_VER > 11 761261272Sdimtemplate <class _Tp = void> 762261272Sdim#else 763227825Stheraventemplate <class _Tp> 764261272Sdim#endif 765261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY less_equal : binary_function<_Tp, _Tp, bool> 766227825Stheraven{ 767261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 768261272Sdim bool operator()(const _Tp& __x, const _Tp& __y) const 769227825Stheraven {return __x <= __y;} 770227825Stheraven}; 771227825Stheraven 772261272Sdim#if _LIBCPP_STD_VER > 11 773261272Sdimtemplate <> 774261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY less_equal<void> 775261272Sdim{ 776261272Sdim template <class _T1, class _T2> 777261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 778261272Sdim auto operator()(_T1&& __t, _T2&& __u) const 779288943Sdim _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))) 780288943Sdim -> decltype (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)) 781288943Sdim { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } 782261272Sdim typedef void is_transparent; 783261272Sdim}; 784261272Sdim#endif 785261272Sdim 786261272Sdim 787261272Sdim#if _LIBCPP_STD_VER > 11 788261272Sdimtemplate <class _Tp = void> 789261272Sdim#else 790227825Stheraventemplate <class _Tp> 791261272Sdim#endif 792261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_and : binary_function<_Tp, _Tp, bool> 793227825Stheraven{ 794261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 795261272Sdim bool operator()(const _Tp& __x, const _Tp& __y) const 796227825Stheraven {return __x && __y;} 797227825Stheraven}; 798227825Stheraven 799261272Sdim#if _LIBCPP_STD_VER > 11 800261272Sdimtemplate <> 801261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_and<void> 802261272Sdim{ 803261272Sdim template <class _T1, class _T2> 804261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 805261272Sdim auto operator()(_T1&& __t, _T2&& __u) const 806288943Sdim _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))) 807288943Sdim -> decltype (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)) 808288943Sdim { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } 809261272Sdim typedef void is_transparent; 810261272Sdim}; 811261272Sdim#endif 812261272Sdim 813261272Sdim 814261272Sdim#if _LIBCPP_STD_VER > 11 815261272Sdimtemplate <class _Tp = void> 816261272Sdim#else 817227825Stheraventemplate <class _Tp> 818261272Sdim#endif 819261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_or : binary_function<_Tp, _Tp, bool> 820227825Stheraven{ 821261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 822261272Sdim bool operator()(const _Tp& __x, const _Tp& __y) const 823227825Stheraven {return __x || __y;} 824227825Stheraven}; 825227825Stheraven 826261272Sdim#if _LIBCPP_STD_VER > 11 827261272Sdimtemplate <> 828261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_or<void> 829261272Sdim{ 830261272Sdim template <class _T1, class _T2> 831261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 832261272Sdim auto operator()(_T1&& __t, _T2&& __u) const 833288943Sdim _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))) 834288943Sdim -> decltype (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)) 835288943Sdim { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } 836261272Sdim typedef void is_transparent; 837261272Sdim}; 838261272Sdim#endif 839261272Sdim 840261272Sdim 841261272Sdim#if _LIBCPP_STD_VER > 11 842261272Sdimtemplate <class _Tp = void> 843261272Sdim#else 844227825Stheraventemplate <class _Tp> 845261272Sdim#endif 846261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_not : unary_function<_Tp, bool> 847227825Stheraven{ 848261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 849261272Sdim bool operator()(const _Tp& __x) const 850227825Stheraven {return !__x;} 851227825Stheraven}; 852227825Stheraven 853261272Sdim#if _LIBCPP_STD_VER > 11 854261272Sdimtemplate <> 855261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_not<void> 856261272Sdim{ 857261272Sdim template <class _Tp> 858261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 859261272Sdim auto operator()(_Tp&& __x) const 860288943Sdim _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x))) 861288943Sdim -> decltype (!_VSTD::forward<_Tp>(__x)) 862288943Sdim { return !_VSTD::forward<_Tp>(__x); } 863261272Sdim typedef void is_transparent; 864261272Sdim}; 865261272Sdim#endif 866261272Sdim 867261272Sdim 868261272Sdim#if _LIBCPP_STD_VER > 11 869261272Sdimtemplate <class _Tp = void> 870261272Sdim#else 871227825Stheraventemplate <class _Tp> 872261272Sdim#endif 873261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_and : binary_function<_Tp, _Tp, _Tp> 874227825Stheraven{ 875261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 876261272Sdim _Tp operator()(const _Tp& __x, const _Tp& __y) const 877227825Stheraven {return __x & __y;} 878227825Stheraven}; 879227825Stheraven 880261272Sdim#if _LIBCPP_STD_VER > 11 881261272Sdimtemplate <> 882261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_and<void> 883261272Sdim{ 884261272Sdim template <class _T1, class _T2> 885261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 886261272Sdim auto operator()(_T1&& __t, _T2&& __u) const 887288943Sdim _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))) 888288943Sdim -> decltype (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)) 889288943Sdim { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } 890261272Sdim typedef void is_transparent; 891261272Sdim}; 892261272Sdim#endif 893261272Sdim 894261272Sdim 895261272Sdim#if _LIBCPP_STD_VER > 11 896261272Sdimtemplate <class _Tp = void> 897261272Sdim#else 898227825Stheraventemplate <class _Tp> 899261272Sdim#endif 900261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_or : binary_function<_Tp, _Tp, _Tp> 901227825Stheraven{ 902261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 903261272Sdim _Tp operator()(const _Tp& __x, const _Tp& __y) const 904227825Stheraven {return __x | __y;} 905227825Stheraven}; 906227825Stheraven 907261272Sdim#if _LIBCPP_STD_VER > 11 908261272Sdimtemplate <> 909261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_or<void> 910261272Sdim{ 911261272Sdim template <class _T1, class _T2> 912261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 913261272Sdim auto operator()(_T1&& __t, _T2&& __u) const 914288943Sdim _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))) 915288943Sdim -> decltype (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)) 916288943Sdim { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } 917261272Sdim typedef void is_transparent; 918261272Sdim}; 919261272Sdim#endif 920261272Sdim 921261272Sdim 922261272Sdim#if _LIBCPP_STD_VER > 11 923261272Sdimtemplate <class _Tp = void> 924261272Sdim#else 925227825Stheraventemplate <class _Tp> 926261272Sdim#endif 927261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_xor : binary_function<_Tp, _Tp, _Tp> 928227825Stheraven{ 929261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 930261272Sdim _Tp operator()(const _Tp& __x, const _Tp& __y) const 931227825Stheraven {return __x ^ __y;} 932227825Stheraven}; 933227825Stheraven 934261272Sdim#if _LIBCPP_STD_VER > 11 935261272Sdimtemplate <> 936261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_xor<void> 937261272Sdim{ 938261272Sdim template <class _T1, class _T2> 939261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 940261272Sdim auto operator()(_T1&& __t, _T2&& __u) const 941288943Sdim _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))) 942288943Sdim -> decltype (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)) 943288943Sdim { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } 944261272Sdim typedef void is_transparent; 945261272Sdim}; 946261272Sdim#endif 947261272Sdim 948261272Sdim 949261272Sdim#if _LIBCPP_STD_VER > 11 950261272Sdimtemplate <class _Tp = void> 951261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_not : unary_function<_Tp, _Tp> 952261272Sdim{ 953261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 954261272Sdim _Tp operator()(const _Tp& __x) const 955261272Sdim {return ~__x;} 956261272Sdim}; 957261272Sdim 958261272Sdimtemplate <> 959261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_not<void> 960261272Sdim{ 961261272Sdim template <class _Tp> 962261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 963261272Sdim auto operator()(_Tp&& __x) const 964288943Sdim _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x))) 965288943Sdim -> decltype (~_VSTD::forward<_Tp>(__x)) 966288943Sdim { return ~_VSTD::forward<_Tp>(__x); } 967261272Sdim typedef void is_transparent; 968261272Sdim}; 969261272Sdim#endif 970261272Sdim 971227825Stheraventemplate <class _Predicate> 972261272Sdimclass _LIBCPP_TYPE_VIS_ONLY unary_negate 973227825Stheraven : public unary_function<typename _Predicate::argument_type, bool> 974227825Stheraven{ 975227825Stheraven _Predicate __pred_; 976227825Stheravenpublic: 977261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 978261272Sdim explicit unary_negate(const _Predicate& __pred) 979227825Stheraven : __pred_(__pred) {} 980261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 981261272Sdim bool operator()(const typename _Predicate::argument_type& __x) const 982227825Stheraven {return !__pred_(__x);} 983227825Stheraven}; 984227825Stheraven 985227825Stheraventemplate <class _Predicate> 986261272Sdiminline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 987227825Stheravenunary_negate<_Predicate> 988227825Stheravennot1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);} 989227825Stheraven 990227825Stheraventemplate <class _Predicate> 991261272Sdimclass _LIBCPP_TYPE_VIS_ONLY binary_negate 992227825Stheraven : public binary_function<typename _Predicate::first_argument_type, 993227825Stheraven typename _Predicate::second_argument_type, 994227825Stheraven bool> 995227825Stheraven{ 996227825Stheraven _Predicate __pred_; 997227825Stheravenpublic: 998261272Sdim _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11 999261272Sdim binary_negate(const _Predicate& __pred) : __pred_(__pred) {} 1000261272Sdim 1001261272Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1002261272Sdim bool operator()(const typename _Predicate::first_argument_type& __x, 1003227825Stheraven const typename _Predicate::second_argument_type& __y) const 1004227825Stheraven {return !__pred_(__x, __y);} 1005227825Stheraven}; 1006227825Stheraven 1007227825Stheraventemplate <class _Predicate> 1008261272Sdiminline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1009227825Stheravenbinary_negate<_Predicate> 1010227825Stheravennot2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);} 1011227825Stheraven 1012227825Stheraventemplate <class __Operation> 1013261272Sdimclass _LIBCPP_TYPE_VIS_ONLY binder1st 1014227825Stheraven : public unary_function<typename __Operation::second_argument_type, 1015227825Stheraven typename __Operation::result_type> 1016227825Stheraven{ 1017227825Stheravenprotected: 1018227825Stheraven __Operation op; 1019227825Stheraven typename __Operation::first_argument_type value; 1020227825Stheravenpublic: 1021227825Stheraven _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x, 1022227825Stheraven const typename __Operation::first_argument_type __y) 1023227825Stheraven : op(__x), value(__y) {} 1024227825Stheraven _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 1025227825Stheraven (typename __Operation::second_argument_type& __x) const 1026227825Stheraven {return op(value, __x);} 1027227825Stheraven _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 1028227825Stheraven (const typename __Operation::second_argument_type& __x) const 1029227825Stheraven {return op(value, __x);} 1030227825Stheraven}; 1031227825Stheraven 1032227825Stheraventemplate <class __Operation, class _Tp> 1033227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1034227825Stheravenbinder1st<__Operation> 1035227825Stheravenbind1st(const __Operation& __op, const _Tp& __x) 1036227825Stheraven {return binder1st<__Operation>(__op, __x);} 1037227825Stheraven 1038227825Stheraventemplate <class __Operation> 1039261272Sdimclass _LIBCPP_TYPE_VIS_ONLY binder2nd 1040227825Stheraven : public unary_function<typename __Operation::first_argument_type, 1041227825Stheraven typename __Operation::result_type> 1042227825Stheraven{ 1043227825Stheravenprotected: 1044227825Stheraven __Operation op; 1045227825Stheraven typename __Operation::second_argument_type value; 1046227825Stheravenpublic: 1047227825Stheraven _LIBCPP_INLINE_VISIBILITY 1048227825Stheraven binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y) 1049227825Stheraven : op(__x), value(__y) {} 1050227825Stheraven _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 1051227825Stheraven ( typename __Operation::first_argument_type& __x) const 1052227825Stheraven {return op(__x, value);} 1053227825Stheraven _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 1054227825Stheraven (const typename __Operation::first_argument_type& __x) const 1055227825Stheraven {return op(__x, value);} 1056227825Stheraven}; 1057227825Stheraven 1058227825Stheraventemplate <class __Operation, class _Tp> 1059227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1060227825Stheravenbinder2nd<__Operation> 1061227825Stheravenbind2nd(const __Operation& __op, const _Tp& __x) 1062227825Stheraven {return binder2nd<__Operation>(__op, __x);} 1063227825Stheraven 1064227825Stheraventemplate <class _Arg, class _Result> 1065261272Sdimclass _LIBCPP_TYPE_VIS_ONLY pointer_to_unary_function 1066227825Stheraven : public unary_function<_Arg, _Result> 1067227825Stheraven{ 1068227825Stheraven _Result (*__f_)(_Arg); 1069227825Stheravenpublic: 1070227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg)) 1071227825Stheraven : __f_(__f) {} 1072227825Stheraven _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const 1073227825Stheraven {return __f_(__x);} 1074227825Stheraven}; 1075227825Stheraven 1076227825Stheraventemplate <class _Arg, class _Result> 1077227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1078227825Stheravenpointer_to_unary_function<_Arg,_Result> 1079227825Stheravenptr_fun(_Result (*__f)(_Arg)) 1080227825Stheraven {return pointer_to_unary_function<_Arg,_Result>(__f);} 1081227825Stheraven 1082227825Stheraventemplate <class _Arg1, class _Arg2, class _Result> 1083261272Sdimclass _LIBCPP_TYPE_VIS_ONLY pointer_to_binary_function 1084227825Stheraven : public binary_function<_Arg1, _Arg2, _Result> 1085227825Stheraven{ 1086227825Stheraven _Result (*__f_)(_Arg1, _Arg2); 1087227825Stheravenpublic: 1088227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2)) 1089227825Stheraven : __f_(__f) {} 1090227825Stheraven _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const 1091227825Stheraven {return __f_(__x, __y);} 1092227825Stheraven}; 1093227825Stheraven 1094227825Stheraventemplate <class _Arg1, class _Arg2, class _Result> 1095227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1096227825Stheravenpointer_to_binary_function<_Arg1,_Arg2,_Result> 1097227825Stheravenptr_fun(_Result (*__f)(_Arg1,_Arg2)) 1098227825Stheraven {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);} 1099227825Stheraven 1100227825Stheraventemplate<class _Sp, class _Tp> 1101261272Sdimclass _LIBCPP_TYPE_VIS_ONLY mem_fun_t : public unary_function<_Tp*, _Sp> 1102227825Stheraven{ 1103227825Stheraven _Sp (_Tp::*__p_)(); 1104227825Stheravenpublic: 1105227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)()) 1106227825Stheraven : __p_(__p) {} 1107227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const 1108227825Stheraven {return (__p->*__p_)();} 1109227825Stheraven}; 1110227825Stheraven 1111227825Stheraventemplate<class _Sp, class _Tp, class _Ap> 1112261272Sdimclass _LIBCPP_TYPE_VIS_ONLY mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp> 1113227825Stheraven{ 1114227825Stheraven _Sp (_Tp::*__p_)(_Ap); 1115227825Stheravenpublic: 1116227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap)) 1117227825Stheraven : __p_(__p) {} 1118227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const 1119227825Stheraven {return (__p->*__p_)(__x);} 1120227825Stheraven}; 1121227825Stheraven 1122227825Stheraventemplate<class _Sp, class _Tp> 1123227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1124227825Stheravenmem_fun_t<_Sp,_Tp> 1125227825Stheravenmem_fun(_Sp (_Tp::*__f)()) 1126227825Stheraven {return mem_fun_t<_Sp,_Tp>(__f);} 1127227825Stheraven 1128227825Stheraventemplate<class _Sp, class _Tp, class _Ap> 1129227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1130227825Stheravenmem_fun1_t<_Sp,_Tp,_Ap> 1131227825Stheravenmem_fun(_Sp (_Tp::*__f)(_Ap)) 1132227825Stheraven {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);} 1133227825Stheraven 1134227825Stheraventemplate<class _Sp, class _Tp> 1135261272Sdimclass _LIBCPP_TYPE_VIS_ONLY mem_fun_ref_t : public unary_function<_Tp, _Sp> 1136227825Stheraven{ 1137227825Stheraven _Sp (_Tp::*__p_)(); 1138227825Stheravenpublic: 1139227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)()) 1140227825Stheraven : __p_(__p) {} 1141227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const 1142227825Stheraven {return (__p.*__p_)();} 1143227825Stheraven}; 1144227825Stheraven 1145227825Stheraventemplate<class _Sp, class _Tp, class _Ap> 1146261272Sdimclass _LIBCPP_TYPE_VIS_ONLY mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp> 1147227825Stheraven{ 1148227825Stheraven _Sp (_Tp::*__p_)(_Ap); 1149227825Stheravenpublic: 1150227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap)) 1151227825Stheraven : __p_(__p) {} 1152227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const 1153227825Stheraven {return (__p.*__p_)(__x);} 1154227825Stheraven}; 1155227825Stheraven 1156227825Stheraventemplate<class _Sp, class _Tp> 1157227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1158227825Stheravenmem_fun_ref_t<_Sp,_Tp> 1159227825Stheravenmem_fun_ref(_Sp (_Tp::*__f)()) 1160227825Stheraven {return mem_fun_ref_t<_Sp,_Tp>(__f);} 1161227825Stheraven 1162227825Stheraventemplate<class _Sp, class _Tp, class _Ap> 1163227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1164227825Stheravenmem_fun1_ref_t<_Sp,_Tp,_Ap> 1165227825Stheravenmem_fun_ref(_Sp (_Tp::*__f)(_Ap)) 1166227825Stheraven {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} 1167227825Stheraven 1168227825Stheraventemplate <class _Sp, class _Tp> 1169261272Sdimclass _LIBCPP_TYPE_VIS_ONLY const_mem_fun_t : public unary_function<const _Tp*, _Sp> 1170227825Stheraven{ 1171227825Stheraven _Sp (_Tp::*__p_)() const; 1172227825Stheravenpublic: 1173227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const) 1174227825Stheraven : __p_(__p) {} 1175227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const 1176227825Stheraven {return (__p->*__p_)();} 1177227825Stheraven}; 1178227825Stheraven 1179227825Stheraventemplate <class _Sp, class _Tp, class _Ap> 1180261272Sdimclass _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp> 1181227825Stheraven{ 1182227825Stheraven _Sp (_Tp::*__p_)(_Ap) const; 1183227825Stheravenpublic: 1184227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const) 1185227825Stheraven : __p_(__p) {} 1186227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const 1187227825Stheraven {return (__p->*__p_)(__x);} 1188227825Stheraven}; 1189227825Stheraven 1190227825Stheraventemplate <class _Sp, class _Tp> 1191227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1192227825Stheravenconst_mem_fun_t<_Sp,_Tp> 1193227825Stheravenmem_fun(_Sp (_Tp::*__f)() const) 1194227825Stheraven {return const_mem_fun_t<_Sp,_Tp>(__f);} 1195227825Stheraven 1196227825Stheraventemplate <class _Sp, class _Tp, class _Ap> 1197227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1198227825Stheravenconst_mem_fun1_t<_Sp,_Tp,_Ap> 1199227825Stheravenmem_fun(_Sp (_Tp::*__f)(_Ap) const) 1200227825Stheraven {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);} 1201227825Stheraven 1202227825Stheraventemplate <class _Sp, class _Tp> 1203261272Sdimclass _LIBCPP_TYPE_VIS_ONLY const_mem_fun_ref_t : public unary_function<_Tp, _Sp> 1204227825Stheraven{ 1205227825Stheraven _Sp (_Tp::*__p_)() const; 1206227825Stheravenpublic: 1207227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const) 1208227825Stheraven : __p_(__p) {} 1209227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const 1210227825Stheraven {return (__p.*__p_)();} 1211227825Stheraven}; 1212227825Stheraven 1213227825Stheraventemplate <class _Sp, class _Tp, class _Ap> 1214261272Sdimclass _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_ref_t 1215227825Stheraven : public binary_function<_Tp, _Ap, _Sp> 1216227825Stheraven{ 1217227825Stheraven _Sp (_Tp::*__p_)(_Ap) const; 1218227825Stheravenpublic: 1219227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const) 1220227825Stheraven : __p_(__p) {} 1221227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const 1222227825Stheraven {return (__p.*__p_)(__x);} 1223227825Stheraven}; 1224227825Stheraven 1225227825Stheraventemplate <class _Sp, class _Tp> 1226227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1227227825Stheravenconst_mem_fun_ref_t<_Sp,_Tp> 1228227825Stheravenmem_fun_ref(_Sp (_Tp::*__f)() const) 1229227825Stheraven {return const_mem_fun_ref_t<_Sp,_Tp>(__f);} 1230227825Stheraven 1231227825Stheraventemplate <class _Sp, class _Tp, class _Ap> 1232227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1233227825Stheravenconst_mem_fun1_ref_t<_Sp,_Tp,_Ap> 1234227825Stheravenmem_fun_ref(_Sp (_Tp::*__f)(_Ap) const) 1235227825Stheraven {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} 1236227825Stheraven 1237227825Stheraven#ifdef _LIBCPP_HAS_NO_VARIADICS 1238227825Stheraven 1239227825Stheraven#include <__functional_03> 1240227825Stheraven 1241227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 1242227825Stheraven 1243227825Stheraventemplate <class _Tp> 1244227825Stheravenclass __mem_fn 1245227825Stheraven : public __weak_result_type<_Tp> 1246227825Stheraven{ 1247227825Stheravenpublic: 1248227825Stheraven // types 1249227825Stheraven typedef _Tp type; 1250227825Stheravenprivate: 1251227825Stheraven type __f_; 1252227825Stheraven 1253227825Stheravenpublic: 1254227825Stheraven _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {} 1255227825Stheraven 1256227825Stheraven // invoke 1257227825Stheraven template <class... _ArgTypes> 1258227825Stheraven _LIBCPP_INLINE_VISIBILITY 1259227825Stheraven typename __invoke_return<type, _ArgTypes...>::type 1260276792Sdim operator() (_ArgTypes&&... __args) const 1261227825Stheraven { 1262227825Stheraven return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...); 1263227825Stheraven } 1264227825Stheraven}; 1265227825Stheraven 1266232924Stheraventemplate<class _Rp, class _Tp> 1267227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1268232924Stheraven__mem_fn<_Rp _Tp::*> 1269232924Stheravenmem_fn(_Rp _Tp::* __pm) 1270227825Stheraven{ 1271232924Stheraven return __mem_fn<_Rp _Tp::*>(__pm); 1272227825Stheraven} 1273227825Stheraven 1274227825Stheraven// bad_function_call 1275227825Stheraven 1276227825Stheravenclass _LIBCPP_EXCEPTION_ABI bad_function_call 1277227825Stheraven : public exception 1278227825Stheraven{ 1279227825Stheraven}; 1280227825Stheraven 1281261272Sdimtemplate<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined 1282227825Stheraven 1283227825Stheravennamespace __function 1284227825Stheraven{ 1285227825Stheraven 1286232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1287227825Stheravenstruct __maybe_derive_from_unary_function 1288227825Stheraven{ 1289227825Stheraven}; 1290227825Stheraven 1291232924Stheraventemplate<class _Rp, class _A1> 1292232924Stheravenstruct __maybe_derive_from_unary_function<_Rp(_A1)> 1293232924Stheraven : public unary_function<_A1, _Rp> 1294227825Stheraven{ 1295227825Stheraven}; 1296227825Stheraven 1297232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1298227825Stheravenstruct __maybe_derive_from_binary_function 1299227825Stheraven{ 1300227825Stheraven}; 1301227825Stheraven 1302232924Stheraventemplate<class _Rp, class _A1, class _A2> 1303232924Stheravenstruct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> 1304232924Stheraven : public binary_function<_A1, _A2, _Rp> 1305227825Stheraven{ 1306227825Stheraven}; 1307227825Stheraven 1308227825Stheraventemplate<class _Fp> class __base; 1309227825Stheraven 1310232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1311232924Stheravenclass __base<_Rp(_ArgTypes...)> 1312227825Stheraven{ 1313227825Stheraven __base(const __base&); 1314227825Stheraven __base& operator=(const __base&); 1315227825Stheravenpublic: 1316227825Stheraven _LIBCPP_INLINE_VISIBILITY __base() {} 1317227825Stheraven _LIBCPP_INLINE_VISIBILITY virtual ~__base() {} 1318227825Stheraven virtual __base* __clone() const = 0; 1319227825Stheraven virtual void __clone(__base*) const = 0; 1320227825Stheraven virtual void destroy() _NOEXCEPT = 0; 1321227825Stheraven virtual void destroy_deallocate() _NOEXCEPT = 0; 1322232924Stheraven virtual _Rp operator()(_ArgTypes&& ...) = 0; 1323227825Stheraven#ifndef _LIBCPP_NO_RTTI 1324227825Stheraven virtual const void* target(const type_info&) const _NOEXCEPT = 0; 1325227825Stheraven virtual const std::type_info& target_type() const _NOEXCEPT = 0; 1326227825Stheraven#endif // _LIBCPP_NO_RTTI 1327227825Stheraven}; 1328227825Stheraven 1329227825Stheraventemplate<class _FD, class _Alloc, class _FB> class __func; 1330227825Stheraven 1331232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1332232924Stheravenclass __func<_Fp, _Alloc, _Rp(_ArgTypes...)> 1333232924Stheraven : public __base<_Rp(_ArgTypes...)> 1334227825Stheraven{ 1335232924Stheraven __compressed_pair<_Fp, _Alloc> __f_; 1336227825Stheravenpublic: 1337227825Stheraven _LIBCPP_INLINE_VISIBILITY 1338232924Stheraven explicit __func(_Fp&& __f) 1339232924Stheraven : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), 1340232924Stheraven _VSTD::forward_as_tuple()) {} 1341227825Stheraven _LIBCPP_INLINE_VISIBILITY 1342232924Stheraven explicit __func(const _Fp& __f, const _Alloc& __a) 1343232924Stheraven : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), 1344232924Stheraven _VSTD::forward_as_tuple(__a)) {} 1345232924Stheraven 1346232924Stheraven _LIBCPP_INLINE_VISIBILITY 1347232924Stheraven explicit __func(const _Fp& __f, _Alloc&& __a) 1348232924Stheraven : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), 1349232924Stheraven _VSTD::forward_as_tuple(_VSTD::move(__a))) {} 1350232924Stheraven 1351232924Stheraven _LIBCPP_INLINE_VISIBILITY 1352232924Stheraven explicit __func(_Fp&& __f, _Alloc&& __a) 1353232924Stheraven : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), 1354232924Stheraven _VSTD::forward_as_tuple(_VSTD::move(__a))) {} 1355232924Stheraven virtual __base<_Rp(_ArgTypes...)>* __clone() const; 1356232924Stheraven virtual void __clone(__base<_Rp(_ArgTypes...)>*) const; 1357227825Stheraven virtual void destroy() _NOEXCEPT; 1358227825Stheraven virtual void destroy_deallocate() _NOEXCEPT; 1359232924Stheraven virtual _Rp operator()(_ArgTypes&& ... __arg); 1360227825Stheraven#ifndef _LIBCPP_NO_RTTI 1361227825Stheraven virtual const void* target(const type_info&) const _NOEXCEPT; 1362227825Stheraven virtual const std::type_info& target_type() const _NOEXCEPT; 1363227825Stheraven#endif // _LIBCPP_NO_RTTI 1364227825Stheraven}; 1365227825Stheraven 1366232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1367232924Stheraven__base<_Rp(_ArgTypes...)>* 1368232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const 1369227825Stheraven{ 1370288943Sdim typedef allocator_traits<_Alloc> __alloc_traits; 1371288943Sdim typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; 1372232924Stheraven _Ap __a(__f_.second()); 1373232924Stheraven typedef __allocator_destructor<_Ap> _Dp; 1374232924Stheraven unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1375227825Stheraven ::new (__hold.get()) __func(__f_.first(), _Alloc(__a)); 1376227825Stheraven return __hold.release(); 1377227825Stheraven} 1378227825Stheraven 1379232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1380227825Stheravenvoid 1381232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const 1382227825Stheraven{ 1383227825Stheraven ::new (__p) __func(__f_.first(), __f_.second()); 1384227825Stheraven} 1385227825Stheraven 1386232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1387227825Stheravenvoid 1388232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT 1389227825Stheraven{ 1390232924Stheraven __f_.~__compressed_pair<_Fp, _Alloc>(); 1391227825Stheraven} 1392227825Stheraven 1393232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1394227825Stheravenvoid 1395232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT 1396227825Stheraven{ 1397288943Sdim typedef allocator_traits<_Alloc> __alloc_traits; 1398288943Sdim typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; 1399232924Stheraven _Ap __a(__f_.second()); 1400232924Stheraven __f_.~__compressed_pair<_Fp, _Alloc>(); 1401227825Stheraven __a.deallocate(this, 1); 1402227825Stheraven} 1403227825Stheraven 1404232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1405232924Stheraven_Rp 1406232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg) 1407227825Stheraven{ 1408288943Sdim typedef __invoke_void_return_wrapper<_Rp> _Invoker; 1409288943Sdim return _Invoker::__call(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...); 1410227825Stheraven} 1411227825Stheraven 1412227825Stheraven#ifndef _LIBCPP_NO_RTTI 1413227825Stheraven 1414232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1415227825Stheravenconst void* 1416232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT 1417227825Stheraven{ 1418232924Stheraven if (__ti == typeid(_Fp)) 1419227825Stheraven return &__f_.first(); 1420227825Stheraven return (const void*)0; 1421227825Stheraven} 1422227825Stheraven 1423232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1424227825Stheravenconst std::type_info& 1425232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT 1426227825Stheraven{ 1427232924Stheraven return typeid(_Fp); 1428227825Stheraven} 1429227825Stheraven 1430227825Stheraven#endif // _LIBCPP_NO_RTTI 1431227825Stheraven 1432227825Stheraven} // __function 1433227825Stheraven 1434232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1435261272Sdimclass _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)> 1436232924Stheraven : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>, 1437232924Stheraven public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> 1438227825Stheraven{ 1439232924Stheraven typedef __function::__base<_Rp(_ArgTypes...)> __base; 1440246468Stheraven typename aligned_storage<3*sizeof(void*)>::type __buf_; 1441227825Stheraven __base* __f_; 1442227825Stheraven 1443232924Stheraven template <class _Fp> 1444227825Stheraven _LIBCPP_INLINE_VISIBILITY 1445232924Stheraven static bool __not_null(const _Fp&) {return true;} 1446232924Stheraven template <class _R2, class ..._Ap> 1447227825Stheraven _LIBCPP_INLINE_VISIBILITY 1448232924Stheraven static bool __not_null(_R2 (*__p)(_Ap...)) {return __p;} 1449232924Stheraven template <class _R2, class _Cp, class ..._Ap> 1450227825Stheraven _LIBCPP_INLINE_VISIBILITY 1451232924Stheraven static bool __not_null(_R2 (_Cp::*__p)(_Ap...)) {return __p;} 1452232924Stheraven template <class _R2, class _Cp, class ..._Ap> 1453227825Stheraven _LIBCPP_INLINE_VISIBILITY 1454232924Stheraven static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const) {return __p;} 1455232924Stheraven template <class _R2, class _Cp, class ..._Ap> 1456227825Stheraven _LIBCPP_INLINE_VISIBILITY 1457232924Stheraven static bool __not_null(_R2 (_Cp::*__p)(_Ap...) volatile) {return __p;} 1458232924Stheraven template <class _R2, class _Cp, class ..._Ap> 1459227825Stheraven _LIBCPP_INLINE_VISIBILITY 1460232924Stheraven static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const volatile) {return __p;} 1461232924Stheraven template <class _R2, class ..._Ap> 1462227825Stheraven _LIBCPP_INLINE_VISIBILITY 1463276792Sdim static bool __not_null(const function<_R2(_Ap...)>& __p) {return !!__p;} 1464227825Stheraven 1465241900Sdim template <class _Fp, bool = !is_same<_Fp, function>::value && 1466241900Sdim __invokable<_Fp&, _ArgTypes...>::value> 1467227825Stheraven struct __callable; 1468232924Stheraven template <class _Fp> 1469232924Stheraven struct __callable<_Fp, true> 1470227825Stheraven { 1471288943Sdim static const bool value = is_same<void, _Rp>::value || 1472232924Stheraven is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type, 1473232924Stheraven _Rp>::value; 1474227825Stheraven }; 1475232924Stheraven template <class _Fp> 1476232924Stheraven struct __callable<_Fp, false> 1477227825Stheraven { 1478227825Stheraven static const bool value = false; 1479227825Stheraven }; 1480227825Stheravenpublic: 1481232924Stheraven typedef _Rp result_type; 1482227825Stheraven 1483227825Stheraven // construct/copy/destroy: 1484227825Stheraven _LIBCPP_INLINE_VISIBILITY 1485227825Stheraven function() _NOEXCEPT : __f_(0) {} 1486227825Stheraven _LIBCPP_INLINE_VISIBILITY 1487227825Stheraven function(nullptr_t) _NOEXCEPT : __f_(0) {} 1488227825Stheraven function(const function&); 1489227825Stheraven function(function&&) _NOEXCEPT; 1490232924Stheraven template<class _Fp> 1491253146Stheraven function(_Fp, typename enable_if 1492253146Stheraven < 1493253146Stheraven __callable<_Fp>::value && 1494253146Stheraven !is_same<_Fp, function>::value 1495253146Stheraven >::type* = 0); 1496227825Stheraven 1497227825Stheraven template<class _Alloc> 1498227825Stheraven _LIBCPP_INLINE_VISIBILITY 1499227825Stheraven function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {} 1500227825Stheraven template<class _Alloc> 1501227825Stheraven _LIBCPP_INLINE_VISIBILITY 1502227825Stheraven function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {} 1503227825Stheraven template<class _Alloc> 1504227825Stheraven function(allocator_arg_t, const _Alloc&, const function&); 1505227825Stheraven template<class _Alloc> 1506227825Stheraven function(allocator_arg_t, const _Alloc&, function&&); 1507232924Stheraven template<class _Fp, class _Alloc> 1508232924Stheraven function(allocator_arg_t, const _Alloc& __a, _Fp __f, 1509232924Stheraven typename enable_if<__callable<_Fp>::value>::type* = 0); 1510227825Stheraven 1511227825Stheraven function& operator=(const function&); 1512227825Stheraven function& operator=(function&&) _NOEXCEPT; 1513227825Stheraven function& operator=(nullptr_t) _NOEXCEPT; 1514232924Stheraven template<class _Fp> 1515227825Stheraven typename enable_if 1516227825Stheraven < 1517253146Stheraven __callable<typename decay<_Fp>::type>::value && 1518253146Stheraven !is_same<typename remove_reference<_Fp>::type, function>::value, 1519227825Stheraven function& 1520227825Stheraven >::type 1521232924Stheraven operator=(_Fp&&); 1522227825Stheraven 1523227825Stheraven ~function(); 1524227825Stheraven 1525227825Stheraven // function modifiers: 1526227825Stheraven void swap(function&) _NOEXCEPT; 1527232924Stheraven template<class _Fp, class _Alloc> 1528227825Stheraven _LIBCPP_INLINE_VISIBILITY 1529232924Stheraven void assign(_Fp&& __f, const _Alloc& __a) 1530232924Stheraven {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);} 1531227825Stheraven 1532227825Stheraven // function capacity: 1533227825Stheraven _LIBCPP_INLINE_VISIBILITY 1534232924Stheraven _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;} 1535227825Stheraven 1536227825Stheraven // deleted overloads close possible hole in the type system 1537227825Stheraven template<class _R2, class... _ArgTypes2> 1538227825Stheraven bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete; 1539227825Stheraven template<class _R2, class... _ArgTypes2> 1540227825Stheraven bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete; 1541227825Stheravenpublic: 1542227825Stheraven // function invocation: 1543232924Stheraven _Rp operator()(_ArgTypes...) const; 1544227825Stheraven 1545227825Stheraven#ifndef _LIBCPP_NO_RTTI 1546227825Stheraven // function target access: 1547227825Stheraven const std::type_info& target_type() const _NOEXCEPT; 1548232924Stheraven template <typename _Tp> _Tp* target() _NOEXCEPT; 1549232924Stheraven template <typename _Tp> const _Tp* target() const _NOEXCEPT; 1550227825Stheraven#endif // _LIBCPP_NO_RTTI 1551227825Stheraven}; 1552227825Stheraven 1553232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1554232924Stheravenfunction<_Rp(_ArgTypes...)>::function(const function& __f) 1555227825Stheraven{ 1556227825Stheraven if (__f.__f_ == 0) 1557227825Stheraven __f_ = 0; 1558227825Stheraven else if (__f.__f_ == (const __base*)&__f.__buf_) 1559227825Stheraven { 1560227825Stheraven __f_ = (__base*)&__buf_; 1561227825Stheraven __f.__f_->__clone(__f_); 1562227825Stheraven } 1563227825Stheraven else 1564227825Stheraven __f_ = __f.__f_->__clone(); 1565227825Stheraven} 1566227825Stheraven 1567232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1568227825Stheraventemplate <class _Alloc> 1569232924Stheravenfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, 1570227825Stheraven const function& __f) 1571227825Stheraven{ 1572227825Stheraven if (__f.__f_ == 0) 1573227825Stheraven __f_ = 0; 1574227825Stheraven else if (__f.__f_ == (const __base*)&__f.__buf_) 1575227825Stheraven { 1576227825Stheraven __f_ = (__base*)&__buf_; 1577227825Stheraven __f.__f_->__clone(__f_); 1578227825Stheraven } 1579227825Stheraven else 1580227825Stheraven __f_ = __f.__f_->__clone(); 1581227825Stheraven} 1582227825Stheraven 1583232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1584232924Stheravenfunction<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT 1585227825Stheraven{ 1586227825Stheraven if (__f.__f_ == 0) 1587227825Stheraven __f_ = 0; 1588227825Stheraven else if (__f.__f_ == (__base*)&__f.__buf_) 1589227825Stheraven { 1590227825Stheraven __f_ = (__base*)&__buf_; 1591227825Stheraven __f.__f_->__clone(__f_); 1592227825Stheraven } 1593227825Stheraven else 1594227825Stheraven { 1595227825Stheraven __f_ = __f.__f_; 1596227825Stheraven __f.__f_ = 0; 1597227825Stheraven } 1598227825Stheraven} 1599227825Stheraven 1600232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1601227825Stheraventemplate <class _Alloc> 1602232924Stheravenfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, 1603227825Stheraven function&& __f) 1604227825Stheraven{ 1605227825Stheraven if (__f.__f_ == 0) 1606227825Stheraven __f_ = 0; 1607227825Stheraven else if (__f.__f_ == (__base*)&__f.__buf_) 1608227825Stheraven { 1609227825Stheraven __f_ = (__base*)&__buf_; 1610227825Stheraven __f.__f_->__clone(__f_); 1611227825Stheraven } 1612227825Stheraven else 1613227825Stheraven { 1614227825Stheraven __f_ = __f.__f_; 1615227825Stheraven __f.__f_ = 0; 1616227825Stheraven } 1617227825Stheraven} 1618227825Stheraven 1619232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1620232924Stheraventemplate <class _Fp> 1621232924Stheravenfunction<_Rp(_ArgTypes...)>::function(_Fp __f, 1622253146Stheraven typename enable_if 1623253146Stheraven < 1624253146Stheraven __callable<_Fp>::value && 1625253146Stheraven !is_same<_Fp, function>::value 1626253146Stheraven >::type*) 1627227825Stheraven : __f_(0) 1628227825Stheraven{ 1629227825Stheraven if (__not_null(__f)) 1630227825Stheraven { 1631232924Stheraven typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF; 1632232924Stheraven if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) 1633227825Stheraven { 1634227825Stheraven __f_ = (__base*)&__buf_; 1635227825Stheraven ::new (__f_) _FF(_VSTD::move(__f)); 1636227825Stheraven } 1637227825Stheraven else 1638227825Stheraven { 1639232924Stheraven typedef allocator<_FF> _Ap; 1640232924Stheraven _Ap __a; 1641232924Stheraven typedef __allocator_destructor<_Ap> _Dp; 1642232924Stheraven unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1643232924Stheraven ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a)); 1644227825Stheraven __f_ = __hold.release(); 1645227825Stheraven } 1646227825Stheraven } 1647227825Stheraven} 1648227825Stheraven 1649232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1650232924Stheraventemplate <class _Fp, class _Alloc> 1651232924Stheravenfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, 1652232924Stheraven typename enable_if<__callable<_Fp>::value>::type*) 1653227825Stheraven : __f_(0) 1654227825Stheraven{ 1655227825Stheraven typedef allocator_traits<_Alloc> __alloc_traits; 1656227825Stheraven if (__not_null(__f)) 1657227825Stheraven { 1658232924Stheraven typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF; 1659288943Sdim typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; 1660276792Sdim _Ap __a(__a0); 1661276792Sdim if (sizeof(_FF) <= sizeof(__buf_) && 1662276792Sdim is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value) 1663227825Stheraven { 1664227825Stheraven __f_ = (__base*)&__buf_; 1665276792Sdim ::new (__f_) _FF(_VSTD::move(__f), _Alloc(__a)); 1666227825Stheraven } 1667227825Stheraven else 1668227825Stheraven { 1669232924Stheraven typedef __allocator_destructor<_Ap> _Dp; 1670232924Stheraven unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1671227825Stheraven ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a)); 1672227825Stheraven __f_ = __hold.release(); 1673227825Stheraven } 1674227825Stheraven } 1675227825Stheraven} 1676227825Stheraven 1677232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1678232924Stheravenfunction<_Rp(_ArgTypes...)>& 1679232924Stheravenfunction<_Rp(_ArgTypes...)>::operator=(const function& __f) 1680227825Stheraven{ 1681227825Stheraven function(__f).swap(*this); 1682227825Stheraven return *this; 1683227825Stheraven} 1684227825Stheraven 1685232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1686232924Stheravenfunction<_Rp(_ArgTypes...)>& 1687232924Stheravenfunction<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT 1688227825Stheraven{ 1689227825Stheraven if (__f_ == (__base*)&__buf_) 1690227825Stheraven __f_->destroy(); 1691227825Stheraven else if (__f_) 1692227825Stheraven __f_->destroy_deallocate(); 1693227825Stheraven __f_ = 0; 1694227825Stheraven if (__f.__f_ == 0) 1695227825Stheraven __f_ = 0; 1696227825Stheraven else if (__f.__f_ == (__base*)&__f.__buf_) 1697227825Stheraven { 1698227825Stheraven __f_ = (__base*)&__buf_; 1699227825Stheraven __f.__f_->__clone(__f_); 1700227825Stheraven } 1701227825Stheraven else 1702227825Stheraven { 1703227825Stheraven __f_ = __f.__f_; 1704227825Stheraven __f.__f_ = 0; 1705227825Stheraven } 1706241900Sdim return *this; 1707227825Stheraven} 1708227825Stheraven 1709232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1710232924Stheravenfunction<_Rp(_ArgTypes...)>& 1711232924Stheravenfunction<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT 1712227825Stheraven{ 1713227825Stheraven if (__f_ == (__base*)&__buf_) 1714227825Stheraven __f_->destroy(); 1715227825Stheraven else if (__f_) 1716227825Stheraven __f_->destroy_deallocate(); 1717227825Stheraven __f_ = 0; 1718241900Sdim return *this; 1719227825Stheraven} 1720227825Stheraven 1721232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1722232924Stheraventemplate <class _Fp> 1723227825Stheraventypename enable_if 1724227825Stheraven< 1725253146Stheraven function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value && 1726253146Stheraven !is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value, 1727232924Stheraven function<_Rp(_ArgTypes...)>& 1728227825Stheraven>::type 1729232924Stheravenfunction<_Rp(_ArgTypes...)>::operator=(_Fp&& __f) 1730227825Stheraven{ 1731232924Stheraven function(_VSTD::forward<_Fp>(__f)).swap(*this); 1732227825Stheraven return *this; 1733227825Stheraven} 1734227825Stheraven 1735232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1736232924Stheravenfunction<_Rp(_ArgTypes...)>::~function() 1737227825Stheraven{ 1738227825Stheraven if (__f_ == (__base*)&__buf_) 1739227825Stheraven __f_->destroy(); 1740227825Stheraven else if (__f_) 1741227825Stheraven __f_->destroy_deallocate(); 1742227825Stheraven} 1743227825Stheraven 1744232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1745227825Stheravenvoid 1746232924Stheravenfunction<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT 1747227825Stheraven{ 1748227825Stheraven if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) 1749227825Stheraven { 1750227825Stheraven typename aligned_storage<sizeof(__buf_)>::type __tempbuf; 1751227825Stheraven __base* __t = (__base*)&__tempbuf; 1752227825Stheraven __f_->__clone(__t); 1753227825Stheraven __f_->destroy(); 1754227825Stheraven __f_ = 0; 1755227825Stheraven __f.__f_->__clone((__base*)&__buf_); 1756227825Stheraven __f.__f_->destroy(); 1757227825Stheraven __f.__f_ = 0; 1758227825Stheraven __f_ = (__base*)&__buf_; 1759227825Stheraven __t->__clone((__base*)&__f.__buf_); 1760227825Stheraven __t->destroy(); 1761227825Stheraven __f.__f_ = (__base*)&__f.__buf_; 1762227825Stheraven } 1763227825Stheraven else if (__f_ == (__base*)&__buf_) 1764227825Stheraven { 1765227825Stheraven __f_->__clone((__base*)&__f.__buf_); 1766227825Stheraven __f_->destroy(); 1767227825Stheraven __f_ = __f.__f_; 1768227825Stheraven __f.__f_ = (__base*)&__f.__buf_; 1769227825Stheraven } 1770227825Stheraven else if (__f.__f_ == (__base*)&__f.__buf_) 1771227825Stheraven { 1772227825Stheraven __f.__f_->__clone((__base*)&__buf_); 1773227825Stheraven __f.__f_->destroy(); 1774227825Stheraven __f.__f_ = __f_; 1775227825Stheraven __f_ = (__base*)&__buf_; 1776227825Stheraven } 1777227825Stheraven else 1778227825Stheraven _VSTD::swap(__f_, __f.__f_); 1779227825Stheraven} 1780227825Stheraven 1781232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1782232924Stheraven_Rp 1783232924Stheravenfunction<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const 1784227825Stheraven{ 1785227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 1786227825Stheraven if (__f_ == 0) 1787227825Stheraven throw bad_function_call(); 1788227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 1789227825Stheraven return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...); 1790227825Stheraven} 1791227825Stheraven 1792227825Stheraven#ifndef _LIBCPP_NO_RTTI 1793227825Stheraven 1794232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1795227825Stheravenconst std::type_info& 1796232924Stheravenfunction<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT 1797227825Stheraven{ 1798227825Stheraven if (__f_ == 0) 1799227825Stheraven return typeid(void); 1800227825Stheraven return __f_->target_type(); 1801227825Stheraven} 1802227825Stheraven 1803232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1804232924Stheraventemplate <typename _Tp> 1805232924Stheraven_Tp* 1806232924Stheravenfunction<_Rp(_ArgTypes...)>::target() _NOEXCEPT 1807227825Stheraven{ 1808227825Stheraven if (__f_ == 0) 1809232924Stheraven return (_Tp*)0; 1810232924Stheraven return (_Tp*)__f_->target(typeid(_Tp)); 1811227825Stheraven} 1812227825Stheraven 1813232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1814232924Stheraventemplate <typename _Tp> 1815232924Stheravenconst _Tp* 1816232924Stheravenfunction<_Rp(_ArgTypes...)>::target() const _NOEXCEPT 1817227825Stheraven{ 1818227825Stheraven if (__f_ == 0) 1819232924Stheraven return (const _Tp*)0; 1820232924Stheraven return (const _Tp*)__f_->target(typeid(_Tp)); 1821227825Stheraven} 1822227825Stheraven 1823227825Stheraven#endif // _LIBCPP_NO_RTTI 1824227825Stheraven 1825232924Stheraventemplate <class _Rp, class... _ArgTypes> 1826227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1827227825Stheravenbool 1828232924Stheravenoperator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;} 1829227825Stheraven 1830232924Stheraventemplate <class _Rp, class... _ArgTypes> 1831227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1832227825Stheravenbool 1833232924Stheravenoperator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;} 1834227825Stheraven 1835232924Stheraventemplate <class _Rp, class... _ArgTypes> 1836227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1837227825Stheravenbool 1838232924Stheravenoperator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;} 1839227825Stheraven 1840232924Stheraventemplate <class _Rp, class... _ArgTypes> 1841227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1842227825Stheravenbool 1843232924Stheravenoperator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;} 1844227825Stheraven 1845232924Stheraventemplate <class _Rp, class... _ArgTypes> 1846227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1847227825Stheravenvoid 1848232924Stheravenswap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT 1849227825Stheraven{return __x.swap(__y);} 1850227825Stheraven 1851227825Stheraventemplate<class _Tp> struct __is_bind_expression : public false_type {}; 1852261272Sdimtemplate<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression 1853227825Stheraven : public __is_bind_expression<typename remove_cv<_Tp>::type> {}; 1854227825Stheraven 1855227825Stheraventemplate<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {}; 1856261272Sdimtemplate<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_placeholder 1857227825Stheraven : public __is_placeholder<typename remove_cv<_Tp>::type> {}; 1858227825Stheraven 1859227825Stheravennamespace placeholders 1860227825Stheraven{ 1861227825Stheraven 1862232924Stheraventemplate <int _Np> struct __ph {}; 1863227825Stheraven 1864261272Sdim_LIBCPP_FUNC_VIS extern __ph<1> _1; 1865261272Sdim_LIBCPP_FUNC_VIS extern __ph<2> _2; 1866261272Sdim_LIBCPP_FUNC_VIS extern __ph<3> _3; 1867261272Sdim_LIBCPP_FUNC_VIS extern __ph<4> _4; 1868261272Sdim_LIBCPP_FUNC_VIS extern __ph<5> _5; 1869261272Sdim_LIBCPP_FUNC_VIS extern __ph<6> _6; 1870261272Sdim_LIBCPP_FUNC_VIS extern __ph<7> _7; 1871261272Sdim_LIBCPP_FUNC_VIS extern __ph<8> _8; 1872261272Sdim_LIBCPP_FUNC_VIS extern __ph<9> _9; 1873261272Sdim_LIBCPP_FUNC_VIS extern __ph<10> _10; 1874227825Stheraven 1875227825Stheraven} // placeholders 1876227825Stheraven 1877232924Stheraventemplate<int _Np> 1878232924Stheravenstruct __is_placeholder<placeholders::__ph<_Np> > 1879232924Stheraven : public integral_constant<int, _Np> {}; 1880227825Stheraven 1881227825Stheraventemplate <class _Tp, class _Uj> 1882227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1883227825Stheraven_Tp& 1884227825Stheraven__mu(reference_wrapper<_Tp> __t, _Uj&) 1885227825Stheraven{ 1886227825Stheraven return __t.get(); 1887227825Stheraven} 1888227825Stheraven 1889227825Stheraventemplate <class _Ti, class ..._Uj, size_t ..._Indx> 1890227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1891227825Stheraventypename __invoke_of<_Ti&, _Uj...>::type 1892227825Stheraven__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) 1893227825Stheraven{ 1894276792Sdim return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...); 1895227825Stheraven} 1896227825Stheraven 1897227825Stheraventemplate <class _Ti, class ..._Uj> 1898227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1899276792Sdimtypename __lazy_enable_if 1900227825Stheraven< 1901227825Stheraven is_bind_expression<_Ti>::value, 1902276792Sdim __invoke_of<_Ti&, _Uj...> 1903227825Stheraven>::type 1904227825Stheraven__mu(_Ti& __ti, tuple<_Uj...>& __uj) 1905227825Stheraven{ 1906227825Stheraven typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices; 1907227825Stheraven return __mu_expand(__ti, __uj, __indices()); 1908227825Stheraven} 1909227825Stheraven 1910227825Stheraventemplate <bool IsPh, class _Ti, class _Uj> 1911227825Stheravenstruct __mu_return2 {}; 1912227825Stheraven 1913227825Stheraventemplate <class _Ti, class _Uj> 1914227825Stheravenstruct __mu_return2<true, _Ti, _Uj> 1915227825Stheraven{ 1916227825Stheraven typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type; 1917227825Stheraven}; 1918227825Stheraven 1919227825Stheraventemplate <class _Ti, class _Uj> 1920227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1921227825Stheraventypename enable_if 1922227825Stheraven< 1923227825Stheraven 0 < is_placeholder<_Ti>::value, 1924227825Stheraven typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type 1925227825Stheraven>::type 1926227825Stheraven__mu(_Ti&, _Uj& __uj) 1927227825Stheraven{ 1928227825Stheraven const size_t _Indx = is_placeholder<_Ti>::value - 1; 1929276792Sdim return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj)); 1930227825Stheraven} 1931227825Stheraven 1932227825Stheraventemplate <class _Ti, class _Uj> 1933227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1934227825Stheraventypename enable_if 1935227825Stheraven< 1936227825Stheraven !is_bind_expression<_Ti>::value && 1937227825Stheraven is_placeholder<_Ti>::value == 0 && 1938227825Stheraven !__is_reference_wrapper<_Ti>::value, 1939227825Stheraven _Ti& 1940227825Stheraven>::type 1941232924Stheraven__mu(_Ti& __ti, _Uj&) 1942227825Stheraven{ 1943227825Stheraven return __ti; 1944227825Stheraven} 1945227825Stheraven 1946227825Stheraventemplate <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh, 1947227825Stheraven class _TupleUj> 1948227825Stheravenstruct ____mu_return; 1949227825Stheraven 1950253146Stheraventemplate <bool _Invokable, class _Ti, class ..._Uj> 1951253146Stheravenstruct ____mu_return_invokable // false 1952253146Stheraven{ 1953253146Stheraven typedef __nat type; 1954253146Stheraven}; 1955253146Stheraven 1956227825Stheraventemplate <class _Ti, class ..._Uj> 1957253146Stheravenstruct ____mu_return_invokable<true, _Ti, _Uj...> 1958227825Stheraven{ 1959227825Stheraven typedef typename __invoke_of<_Ti&, _Uj...>::type type; 1960227825Stheraven}; 1961227825Stheraven 1962253146Stheraventemplate <class _Ti, class ..._Uj> 1963253146Stheravenstruct ____mu_return<_Ti, false, true, false, tuple<_Uj...> > 1964253146Stheraven : public ____mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...> 1965253146Stheraven{ 1966253146Stheraven}; 1967253146Stheraven 1968227825Stheraventemplate <class _Ti, class _TupleUj> 1969227825Stheravenstruct ____mu_return<_Ti, false, false, true, _TupleUj> 1970227825Stheraven{ 1971227825Stheraven typedef typename tuple_element<is_placeholder<_Ti>::value - 1, 1972227825Stheraven _TupleUj>::type&& type; 1973227825Stheraven}; 1974227825Stheraven 1975227825Stheraventemplate <class _Ti, class _TupleUj> 1976227825Stheravenstruct ____mu_return<_Ti, true, false, false, _TupleUj> 1977227825Stheraven{ 1978227825Stheraven typedef typename _Ti::type& type; 1979227825Stheraven}; 1980227825Stheraven 1981227825Stheraventemplate <class _Ti, class _TupleUj> 1982227825Stheravenstruct ____mu_return<_Ti, false, false, false, _TupleUj> 1983227825Stheraven{ 1984227825Stheraven typedef _Ti& type; 1985227825Stheraven}; 1986227825Stheraven 1987227825Stheraventemplate <class _Ti, class _TupleUj> 1988227825Stheravenstruct __mu_return 1989227825Stheraven : public ____mu_return<_Ti, 1990227825Stheraven __is_reference_wrapper<_Ti>::value, 1991227825Stheraven is_bind_expression<_Ti>::value, 1992249989Sdim 0 < is_placeholder<_Ti>::value && 1993249989Sdim is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value, 1994227825Stheraven _TupleUj> 1995227825Stheraven{ 1996227825Stheraven}; 1997227825Stheraven 1998232924Stheraventemplate <class _Fp, class _BoundArgs, class _TupleUj> 1999288943Sdimstruct __is_valid_bind_return 2000249989Sdim{ 2001249989Sdim static const bool value = false; 2002249989Sdim}; 2003249989Sdim 2004249989Sdimtemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 2005288943Sdimstruct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> 2006249989Sdim{ 2007249989Sdim static const bool value = __invokable<_Fp, 2008249989Sdim typename __mu_return<_BoundArgs, _TupleUj>::type...>::value; 2009249989Sdim}; 2010249989Sdim 2011249989Sdimtemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 2012288943Sdimstruct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> 2013249989Sdim{ 2014249989Sdim static const bool value = __invokable<_Fp, 2015249989Sdim typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value; 2016249989Sdim}; 2017249989Sdim 2018249989Sdimtemplate <class _Fp, class _BoundArgs, class _TupleUj, 2019288943Sdim bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value> 2020227825Stheravenstruct __bind_return; 2021227825Stheraven 2022232924Stheraventemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 2023249989Sdimstruct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> 2024227825Stheraven{ 2025227825Stheraven typedef typename __invoke_of 2026227825Stheraven < 2027232924Stheraven _Fp&, 2028227825Stheraven typename __mu_return 2029227825Stheraven < 2030227825Stheraven _BoundArgs, 2031227825Stheraven _TupleUj 2032227825Stheraven >::type... 2033227825Stheraven >::type type; 2034227825Stheraven}; 2035227825Stheraven 2036232924Stheraventemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 2037249989Sdimstruct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> 2038227825Stheraven{ 2039227825Stheraven typedef typename __invoke_of 2040227825Stheraven < 2041232924Stheraven _Fp&, 2042227825Stheraven typename __mu_return 2043227825Stheraven < 2044227825Stheraven const _BoundArgs, 2045227825Stheraven _TupleUj 2046227825Stheraven >::type... 2047227825Stheraven >::type type; 2048227825Stheraven}; 2049227825Stheraven 2050232924Stheraventemplate <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args> 2051227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2052232924Stheraventypename __bind_return<_Fp, _BoundArgs, _Args>::type 2053232924Stheraven__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, 2054227825Stheraven _Args&& __args) 2055227825Stheraven{ 2056276792Sdim return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...); 2057227825Stheraven} 2058227825Stheraven 2059232924Stheraventemplate<class _Fp, class ..._BoundArgs> 2060227825Stheravenclass __bind 2061232924Stheraven : public __weak_result_type<typename decay<_Fp>::type> 2062227825Stheraven{ 2063249989Sdimprotected: 2064232924Stheraven typedef typename decay<_Fp>::type _Fd; 2065227825Stheraven typedef tuple<typename decay<_BoundArgs>::type...> _Td; 2066249989Sdimprivate: 2067227825Stheraven _Fd __f_; 2068227825Stheraven _Td __bound_args_; 2069227825Stheraven 2070227825Stheraven typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices; 2071227825Stheravenpublic: 2072227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2073227825Stheraven 2074227825Stheraven _LIBCPP_INLINE_VISIBILITY 2075227825Stheraven __bind(const __bind& __b) 2076227825Stheraven : __f_(__b.__f_), 2077227825Stheraven __bound_args_(__b.__bound_args_) {} 2078227825Stheraven 2079227825Stheraven _LIBCPP_INLINE_VISIBILITY 2080227825Stheraven __bind& operator=(const __bind& __b) 2081227825Stheraven { 2082227825Stheraven __f_ = __b.__f_; 2083227825Stheraven __bound_args_ = __b.__bound_args_; 2084227825Stheraven return *this; 2085227825Stheraven } 2086227825Stheraven 2087227825Stheraven _LIBCPP_INLINE_VISIBILITY 2088227825Stheraven __bind(__bind&& __b) 2089227825Stheraven : __f_(_VSTD::move(__b.__f_)), 2090227825Stheraven __bound_args_(_VSTD::move(__b.__bound_args_)) {} 2091227825Stheraven 2092227825Stheraven _LIBCPP_INLINE_VISIBILITY 2093227825Stheraven __bind& operator=(__bind&& __b) 2094227825Stheraven { 2095227825Stheraven __f_ = _VSTD::move(__b.__f_); 2096227825Stheraven __bound_args_ = _VSTD::move(__b.__bound_args_); 2097227825Stheraven return *this; 2098227825Stheraven } 2099227825Stheraven 2100227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2101227825Stheraven 2102241900Sdim template <class _Gp, class ..._BA, 2103241900Sdim class = typename enable_if 2104241900Sdim < 2105253146Stheraven is_constructible<_Fd, _Gp>::value && 2106253146Stheraven !is_same<typename remove_reference<_Gp>::type, 2107253146Stheraven __bind>::value 2108241900Sdim >::type> 2109227825Stheraven _LIBCPP_INLINE_VISIBILITY 2110232924Stheraven explicit __bind(_Gp&& __f, _BA&& ...__bound_args) 2111232924Stheraven : __f_(_VSTD::forward<_Gp>(__f)), 2112227825Stheraven __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {} 2113227825Stheraven 2114227825Stheraven template <class ..._Args> 2115227825Stheraven _LIBCPP_INLINE_VISIBILITY 2116227825Stheraven typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type 2117227825Stheraven operator()(_Args&& ...__args) 2118227825Stheraven { 2119227825Stheraven return __apply_functor(__f_, __bound_args_, __indices(), 2120227825Stheraven tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); 2121227825Stheraven } 2122227825Stheraven 2123227825Stheraven template <class ..._Args> 2124227825Stheraven _LIBCPP_INLINE_VISIBILITY 2125249989Sdim typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type 2126227825Stheraven operator()(_Args&& ...__args) const 2127227825Stheraven { 2128227825Stheraven return __apply_functor(__f_, __bound_args_, __indices(), 2129227825Stheraven tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); 2130227825Stheraven } 2131227825Stheraven}; 2132227825Stheraven 2133232924Stheraventemplate<class _Fp, class ..._BoundArgs> 2134232924Stheravenstruct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {}; 2135227825Stheraven 2136232924Stheraventemplate<class _Rp, class _Fp, class ..._BoundArgs> 2137227825Stheravenclass __bind_r 2138232924Stheraven : public __bind<_Fp, _BoundArgs...> 2139227825Stheraven{ 2140232924Stheraven typedef __bind<_Fp, _BoundArgs...> base; 2141249989Sdim typedef typename base::_Fd _Fd; 2142249989Sdim typedef typename base::_Td _Td; 2143227825Stheravenpublic: 2144232924Stheraven typedef _Rp result_type; 2145227825Stheraven 2146227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2147227825Stheraven 2148227825Stheraven _LIBCPP_INLINE_VISIBILITY 2149227825Stheraven __bind_r(const __bind_r& __b) 2150227825Stheraven : base(_VSTD::forward<const base&>(__b)) {} 2151227825Stheraven 2152227825Stheraven _LIBCPP_INLINE_VISIBILITY 2153227825Stheraven __bind_r& operator=(const __bind_r& __b) 2154227825Stheraven { 2155227825Stheraven base::operator=(_VSTD::forward<const base&>(__b)); 2156227825Stheraven return *this; 2157227825Stheraven } 2158227825Stheraven 2159227825Stheraven _LIBCPP_INLINE_VISIBILITY 2160227825Stheraven __bind_r(__bind_r&& __b) 2161227825Stheraven : base(_VSTD::forward<base>(__b)) {} 2162227825Stheraven 2163227825Stheraven _LIBCPP_INLINE_VISIBILITY 2164227825Stheraven __bind_r& operator=(__bind_r&& __b) 2165227825Stheraven { 2166227825Stheraven base::operator=(_VSTD::forward<base>(__b)); 2167227825Stheraven return *this; 2168227825Stheraven } 2169227825Stheraven 2170227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2171227825Stheraven 2172253146Stheraven template <class _Gp, class ..._BA, 2173253146Stheraven class = typename enable_if 2174253146Stheraven < 2175253146Stheraven is_constructible<_Fd, _Gp>::value && 2176253146Stheraven !is_same<typename remove_reference<_Gp>::type, 2177253146Stheraven __bind_r>::value 2178253146Stheraven >::type> 2179227825Stheraven _LIBCPP_INLINE_VISIBILITY 2180232924Stheraven explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args) 2181232924Stheraven : base(_VSTD::forward<_Gp>(__f), 2182227825Stheraven _VSTD::forward<_BA>(__bound_args)...) {} 2183227825Stheraven 2184227825Stheraven template <class ..._Args> 2185227825Stheraven _LIBCPP_INLINE_VISIBILITY 2186249989Sdim typename enable_if 2187249989Sdim < 2188249989Sdim is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type, 2189288943Sdim result_type>::value || is_void<_Rp>::value, 2190249989Sdim result_type 2191249989Sdim >::type 2192227825Stheraven operator()(_Args&& ...__args) 2193227825Stheraven { 2194288943Sdim typedef __invoke_void_return_wrapper<_Rp> _Invoker; 2195288943Sdim return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...); 2196227825Stheraven } 2197227825Stheraven 2198227825Stheraven template <class ..._Args> 2199227825Stheraven _LIBCPP_INLINE_VISIBILITY 2200249989Sdim typename enable_if 2201249989Sdim < 2202249989Sdim is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type, 2203288943Sdim result_type>::value || is_void<_Rp>::value, 2204249989Sdim result_type 2205249989Sdim >::type 2206227825Stheraven operator()(_Args&& ...__args) const 2207227825Stheraven { 2208288943Sdim typedef __invoke_void_return_wrapper<_Rp> _Invoker; 2209288943Sdim return _Invoker::__call(static_cast<base const&>(*this), _VSTD::forward<_Args>(__args)...); 2210227825Stheraven } 2211227825Stheraven}; 2212227825Stheraven 2213232924Stheraventemplate<class _Rp, class _Fp, class ..._BoundArgs> 2214232924Stheravenstruct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; 2215227825Stheraven 2216232924Stheraventemplate<class _Fp, class ..._BoundArgs> 2217227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2218232924Stheraven__bind<_Fp, _BoundArgs...> 2219232924Stheravenbind(_Fp&& __f, _BoundArgs&&... __bound_args) 2220227825Stheraven{ 2221232924Stheraven typedef __bind<_Fp, _BoundArgs...> type; 2222232924Stheraven return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); 2223227825Stheraven} 2224227825Stheraven 2225232924Stheraventemplate<class _Rp, class _Fp, class ..._BoundArgs> 2226227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2227232924Stheraven__bind_r<_Rp, _Fp, _BoundArgs...> 2228232924Stheravenbind(_Fp&& __f, _BoundArgs&&... __bound_args) 2229227825Stheraven{ 2230232924Stheraven typedef __bind_r<_Rp, _Fp, _BoundArgs...> type; 2231232924Stheraven return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); 2232227825Stheraven} 2233227825Stheraven 2234227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2235227825Stheraven 2236227825Stheraventemplate <> 2237261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<bool> 2238227825Stheraven : public unary_function<bool, size_t> 2239227825Stheraven{ 2240227825Stheraven _LIBCPP_INLINE_VISIBILITY 2241227825Stheraven size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2242227825Stheraven}; 2243227825Stheraven 2244227825Stheraventemplate <> 2245261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<char> 2246227825Stheraven : public unary_function<char, size_t> 2247227825Stheraven{ 2248227825Stheraven _LIBCPP_INLINE_VISIBILITY 2249227825Stheraven size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2250227825Stheraven}; 2251227825Stheraven 2252227825Stheraventemplate <> 2253261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<signed char> 2254227825Stheraven : public unary_function<signed char, size_t> 2255227825Stheraven{ 2256227825Stheraven _LIBCPP_INLINE_VISIBILITY 2257227825Stheraven size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2258227825Stheraven}; 2259227825Stheraven 2260227825Stheraventemplate <> 2261261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned char> 2262227825Stheraven : public unary_function<unsigned char, size_t> 2263227825Stheraven{ 2264227825Stheraven _LIBCPP_INLINE_VISIBILITY 2265227825Stheraven size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2266227825Stheraven}; 2267227825Stheraven 2268227825Stheraven#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 2269227825Stheraven 2270227825Stheraventemplate <> 2271261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<char16_t> 2272227825Stheraven : public unary_function<char16_t, size_t> 2273227825Stheraven{ 2274227825Stheraven _LIBCPP_INLINE_VISIBILITY 2275227825Stheraven size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2276227825Stheraven}; 2277227825Stheraven 2278227825Stheraventemplate <> 2279261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<char32_t> 2280227825Stheraven : public unary_function<char32_t, size_t> 2281227825Stheraven{ 2282227825Stheraven _LIBCPP_INLINE_VISIBILITY 2283227825Stheraven size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2284227825Stheraven}; 2285227825Stheraven 2286227825Stheraven#endif // _LIBCPP_HAS_NO_UNICODE_CHARS 2287227825Stheraven 2288227825Stheraventemplate <> 2289261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<wchar_t> 2290227825Stheraven : public unary_function<wchar_t, size_t> 2291227825Stheraven{ 2292227825Stheraven _LIBCPP_INLINE_VISIBILITY 2293227825Stheraven size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2294227825Stheraven}; 2295227825Stheraven 2296227825Stheraventemplate <> 2297261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<short> 2298227825Stheraven : public unary_function<short, size_t> 2299227825Stheraven{ 2300227825Stheraven _LIBCPP_INLINE_VISIBILITY 2301227825Stheraven size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2302227825Stheraven}; 2303227825Stheraven 2304227825Stheraventemplate <> 2305261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned short> 2306227825Stheraven : public unary_function<unsigned short, size_t> 2307227825Stheraven{ 2308227825Stheraven _LIBCPP_INLINE_VISIBILITY 2309227825Stheraven size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2310227825Stheraven}; 2311227825Stheraven 2312227825Stheraventemplate <> 2313261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<int> 2314227825Stheraven : public unary_function<int, size_t> 2315227825Stheraven{ 2316227825Stheraven _LIBCPP_INLINE_VISIBILITY 2317227825Stheraven size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2318227825Stheraven}; 2319227825Stheraven 2320227825Stheraventemplate <> 2321261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned int> 2322227825Stheraven : public unary_function<unsigned int, size_t> 2323227825Stheraven{ 2324227825Stheraven _LIBCPP_INLINE_VISIBILITY 2325227825Stheraven size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2326227825Stheraven}; 2327227825Stheraven 2328227825Stheraventemplate <> 2329261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<long> 2330227825Stheraven : public unary_function<long, size_t> 2331227825Stheraven{ 2332227825Stheraven _LIBCPP_INLINE_VISIBILITY 2333227825Stheraven size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2334227825Stheraven}; 2335227825Stheraven 2336227825Stheraventemplate <> 2337261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long> 2338227825Stheraven : public unary_function<unsigned long, size_t> 2339227825Stheraven{ 2340227825Stheraven _LIBCPP_INLINE_VISIBILITY 2341227825Stheraven size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2342227825Stheraven}; 2343227825Stheraven 2344227825Stheraventemplate <> 2345261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<long long> 2346232924Stheraven : public __scalar_hash<long long> 2347227825Stheraven{ 2348227825Stheraven}; 2349227825Stheraven 2350227825Stheraventemplate <> 2351261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long long> 2352232924Stheraven : public __scalar_hash<unsigned long long> 2353227825Stheraven{ 2354227825Stheraven}; 2355227825Stheraven 2356227825Stheraventemplate <> 2357261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<float> 2358232924Stheraven : public __scalar_hash<float> 2359227825Stheraven{ 2360227825Stheraven _LIBCPP_INLINE_VISIBILITY 2361227825Stheraven size_t operator()(float __v) const _NOEXCEPT 2362227825Stheraven { 2363232924Stheraven // -0.0 and 0.0 should return same hash 2364232924Stheraven if (__v == 0) 2365232924Stheraven return 0; 2366232924Stheraven return __scalar_hash<float>::operator()(__v); 2367227825Stheraven } 2368227825Stheraven}; 2369227825Stheraven 2370227825Stheraventemplate <> 2371261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<double> 2372232924Stheraven : public __scalar_hash<double> 2373227825Stheraven{ 2374227825Stheraven _LIBCPP_INLINE_VISIBILITY 2375227825Stheraven size_t operator()(double __v) const _NOEXCEPT 2376227825Stheraven { 2377232924Stheraven // -0.0 and 0.0 should return same hash 2378232924Stheraven if (__v == 0) 2379232924Stheraven return 0; 2380232924Stheraven return __scalar_hash<double>::operator()(__v); 2381227825Stheraven } 2382227825Stheraven}; 2383227825Stheraven 2384227825Stheraventemplate <> 2385261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<long double> 2386232924Stheraven : public __scalar_hash<long double> 2387227825Stheraven{ 2388227825Stheraven _LIBCPP_INLINE_VISIBILITY 2389227825Stheraven size_t operator()(long double __v) const _NOEXCEPT 2390227825Stheraven { 2391232924Stheraven // -0.0 and 0.0 should return same hash 2392227825Stheraven if (__v == 0) 2393227825Stheraven return 0; 2394232924Stheraven#if defined(__i386__) 2395232924Stheraven // Zero out padding bits 2396232924Stheraven union 2397232924Stheraven { 2398232924Stheraven long double __t; 2399232924Stheraven struct 2400232924Stheraven { 2401232924Stheraven size_t __a; 2402232924Stheraven size_t __b; 2403232924Stheraven size_t __c; 2404232924Stheraven size_t __d; 2405289082Sdim } __s; 2406232924Stheraven } __u; 2407289082Sdim __u.__s.__a = 0; 2408289082Sdim __u.__s.__b = 0; 2409289082Sdim __u.__s.__c = 0; 2410289082Sdim __u.__s.__d = 0; 2411232924Stheraven __u.__t = __v; 2412289082Sdim return __u.__s.__a ^ __u.__s.__b ^ __u.__s.__c ^ __u.__s.__d; 2413232924Stheraven#elif defined(__x86_64__) 2414232924Stheraven // Zero out padding bits 2415232924Stheraven union 2416232924Stheraven { 2417232924Stheraven long double __t; 2418232924Stheraven struct 2419232924Stheraven { 2420232924Stheraven size_t __a; 2421232924Stheraven size_t __b; 2422289082Sdim } __s; 2423232924Stheraven } __u; 2424289082Sdim __u.__s.__a = 0; 2425289082Sdim __u.__s.__b = 0; 2426232924Stheraven __u.__t = __v; 2427289082Sdim return __u.__s.__a ^ __u.__s.__b; 2428232924Stheraven#else 2429232924Stheraven return __scalar_hash<long double>::operator()(__v); 2430232924Stheraven#endif 2431227825Stheraven } 2432227825Stheraven}; 2433227825Stheraven 2434261272Sdim#if _LIBCPP_STD_VER > 11 2435261272Sdimtemplate <class _Tp> 2436261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash 2437261272Sdim : public unary_function<_Tp, size_t> 2438261272Sdim{ 2439261272Sdim static_assert(is_enum<_Tp>::value, "This hash only works for enumeration types"); 2440261272Sdim 2441261272Sdim _LIBCPP_INLINE_VISIBILITY 2442261272Sdim size_t operator()(_Tp __v) const _NOEXCEPT 2443261272Sdim { 2444261272Sdim typedef typename underlying_type<_Tp>::type type; 2445261272Sdim return hash<type>{}(static_cast<type>(__v)); 2446261272Sdim } 2447261272Sdim}; 2448261272Sdim#endif 2449261272Sdim 2450288943Sdim 2451288943Sdim#if _LIBCPP_STD_VER > 14 2452288943Sdimtemplate <class _Fn, class ..._Args> 2453288943Sdimresult_of_t<_Fn&&(_Args&&...)> 2454288943Sdiminvoke(_Fn&& __f, _Args&&... __args) { 2455288943Sdim return __invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...); 2456288943Sdim} 2457288943Sdim#endif 2458288943Sdim 2459227825Stheraven// struct hash<T*> in <memory> 2460227825Stheraven 2461227825Stheraven_LIBCPP_END_NAMESPACE_STD 2462227825Stheraven 2463227825Stheraven#endif // _LIBCPP_FUNCTIONAL 2464