functional revision 246468
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> 59227825Stheraven 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 71227825Stheraventemplate <class T> 72227825Stheravenstruct plus : binary_function<T, T, T> 73227825Stheraven{ 74227825Stheraven T operator()(const T& x, const T& y) const; 75227825Stheraven}; 76227825Stheraven 77227825Stheraventemplate <class T> 78227825Stheravenstruct minus : binary_function<T, T, T> 79227825Stheraven{ 80227825Stheraven T operator()(const T& x, const T& y) const; 81227825Stheraven}; 82227825Stheraven 83227825Stheraventemplate <class T> 84227825Stheravenstruct multiplies : binary_function<T, T, T> 85227825Stheraven{ 86227825Stheraven T operator()(const T& x, const T& y) const; 87227825Stheraven}; 88227825Stheraven 89227825Stheraventemplate <class T> 90227825Stheravenstruct divides : binary_function<T, T, T> 91227825Stheraven{ 92227825Stheraven T operator()(const T& x, const T& y) const; 93227825Stheraven}; 94227825Stheraven 95227825Stheraventemplate <class T> 96227825Stheravenstruct modulus : binary_function<T, T, T> 97227825Stheraven{ 98227825Stheraven T operator()(const T& x, const T& y) const; 99227825Stheraven}; 100227825Stheraven 101227825Stheraventemplate <class T> 102227825Stheravenstruct negate : unary_function<T, T> 103227825Stheraven{ 104227825Stheraven T operator()(const T& x) const; 105227825Stheraven}; 106227825Stheraven 107227825Stheraventemplate <class T> 108227825Stheravenstruct equal_to : binary_function<T, T, bool> 109227825Stheraven{ 110227825Stheraven bool operator()(const T& x, const T& y) const; 111227825Stheraven}; 112227825Stheraven 113227825Stheraventemplate <class T> 114227825Stheravenstruct not_equal_to : binary_function<T, T, bool> 115227825Stheraven{ 116227825Stheraven bool operator()(const T& x, const T& y) const; 117227825Stheraven}; 118227825Stheraven 119227825Stheraventemplate <class T> 120227825Stheravenstruct greater : binary_function<T, T, bool> 121227825Stheraven{ 122227825Stheraven bool operator()(const T& x, const T& y) const; 123227825Stheraven}; 124227825Stheraven 125227825Stheraventemplate <class T> 126227825Stheravenstruct less : binary_function<T, T, bool> 127227825Stheraven{ 128227825Stheraven bool operator()(const T& x, const T& y) const; 129227825Stheraven}; 130227825Stheraven 131227825Stheraventemplate <class T> 132227825Stheravenstruct greater_equal : binary_function<T, T, bool> 133227825Stheraven{ 134227825Stheraven bool operator()(const T& x, const T& y) const; 135227825Stheraven}; 136227825Stheraven 137227825Stheraventemplate <class T> 138227825Stheravenstruct less_equal : binary_function<T, T, bool> 139227825Stheraven{ 140227825Stheraven bool operator()(const T& x, const T& y) const; 141227825Stheraven}; 142227825Stheraven 143227825Stheraventemplate <class T> 144227825Stheravenstruct logical_and : binary_function<T, T, bool> 145227825Stheraven{ 146227825Stheraven bool operator()(const T& x, const T& y) const; 147227825Stheraven}; 148227825Stheraven 149227825Stheraventemplate <class T> 150227825Stheravenstruct logical_or : binary_function<T, T, bool> 151227825Stheraven{ 152227825Stheraven bool operator()(const T& x, const T& y) const; 153227825Stheraven}; 154227825Stheraven 155227825Stheraventemplate <class T> 156227825Stheravenstruct logical_not : unary_function<T, bool> 157227825Stheraven{ 158227825Stheraven bool operator()(const T& x) const; 159227825Stheraven}; 160227825Stheraven 161227825Stheraventemplate <class Predicate> 162227825Stheravenclass unary_negate 163227825Stheraven : public unary_function<typename Predicate::argument_type, bool> 164227825Stheraven{ 165227825Stheravenpublic: 166227825Stheraven explicit unary_negate(const Predicate& pred); 167227825Stheraven bool operator()(const typename Predicate::argument_type& x) const; 168227825Stheraven}; 169227825Stheraven 170227825Stheraventemplate <class Predicate> unary_negate<Predicate> not1(const Predicate& pred); 171227825Stheraven 172227825Stheraventemplate <class Predicate> 173227825Stheravenclass binary_negate 174227825Stheraven : public binary_function<typename Predicate::first_argument_type, 175227825Stheraven typename Predicate::second_argument_type, 176227825Stheraven bool> 177227825Stheraven{ 178227825Stheravenpublic: 179227825Stheraven explicit binary_negate(const Predicate& pred); 180227825Stheraven bool operator()(const typename Predicate::first_argument_type& x, 181227825Stheraven const typename Predicate::second_argument_type& y) const; 182227825Stheraven}; 183227825Stheraven 184227825Stheraventemplate <class Predicate> binary_negate<Predicate> not2(const Predicate& pred); 185227825Stheraven 186227825Stheraventemplate<class T> struct is_bind_expression; 187227825Stheraventemplate<class T> struct is_placeholder; 188227825Stheraven 189227825Stheraventemplate<class Fn, class... BoundArgs> 190227825Stheraven unspecified bind(Fn&&, BoundArgs&&...); 191227825Stheraventemplate<class R, class Fn, class... BoundArgs> 192227825Stheraven unspecified bind(Fn&&, BoundArgs&&...); 193227825Stheraven 194227825Stheravennamespace placeholders { 195227825Stheraven // M is the implementation-defined number of placeholders 196227825Stheraven extern unspecified _1; 197227825Stheraven extern unspecified _2; 198227825Stheraven . 199227825Stheraven . 200227825Stheraven . 201232924Stheraven extern unspecified _Mp; 202227825Stheraven} 203227825Stheraven 204227825Stheraventemplate <class Operation> 205227825Stheravenclass binder1st 206227825Stheraven : public unary_function<typename Operation::second_argument_type, 207227825Stheraven typename Operation::result_type> 208227825Stheraven{ 209227825Stheravenprotected: 210227825Stheraven Operation op; 211227825Stheraven typename Operation::first_argument_type value; 212227825Stheravenpublic: 213227825Stheraven binder1st(const Operation& x, const typename Operation::first_argument_type y); 214227825Stheraven typename Operation::result_type operator()( typename Operation::second_argument_type& x) const; 215227825Stheraven typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const; 216227825Stheraven}; 217227825Stheraven 218227825Stheraventemplate <class Operation, class T> 219227825Stheravenbinder1st<Operation> bind1st(const Operation& op, const T& x); 220227825Stheraven 221227825Stheraventemplate <class Operation> 222227825Stheravenclass binder2nd 223227825Stheraven : public unary_function<typename Operation::first_argument_type, 224227825Stheraven typename Operation::result_type> 225227825Stheraven{ 226227825Stheravenprotected: 227227825Stheraven Operation op; 228227825Stheraven typename Operation::second_argument_type value; 229227825Stheravenpublic: 230227825Stheraven binder2nd(const Operation& x, const typename Operation::second_argument_type y); 231227825Stheraven typename Operation::result_type operator()( typename Operation::first_argument_type& x) const; 232227825Stheraven typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const; 233227825Stheraven}; 234227825Stheraven 235227825Stheraventemplate <class Operation, class T> 236227825Stheravenbinder2nd<Operation> bind2nd(const Operation& op, const T& x); 237227825Stheraven 238227825Stheraventemplate <class Arg, class Result> 239227825Stheravenclass pointer_to_unary_function : public unary_function<Arg, Result> 240227825Stheraven{ 241227825Stheravenpublic: 242227825Stheraven explicit pointer_to_unary_function(Result (*f)(Arg)); 243227825Stheraven Result operator()(Arg x) const; 244227825Stheraven}; 245227825Stheraven 246227825Stheraventemplate <class Arg, class Result> 247227825Stheravenpointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg)); 248227825Stheraven 249227825Stheraventemplate <class Arg1, class Arg2, class Result> 250227825Stheravenclass pointer_to_binary_function : public binary_function<Arg1, Arg2, Result> 251227825Stheraven{ 252227825Stheravenpublic: 253227825Stheraven explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)); 254227825Stheraven Result operator()(Arg1 x, Arg2 y) const; 255227825Stheraven}; 256227825Stheraven 257227825Stheraventemplate <class Arg1, class Arg2, class Result> 258227825Stheravenpointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2)); 259227825Stheraven 260227825Stheraventemplate<class S, class T> 261227825Stheravenclass mem_fun_t : public unary_function<T*, S> 262227825Stheraven{ 263227825Stheravenpublic: 264227825Stheraven explicit mem_fun_t(S (T::*p)()); 265227825Stheraven S operator()(T* p) const; 266227825Stheraven}; 267227825Stheraven 268227825Stheraventemplate<class S, class T, class A> 269227825Stheravenclass mem_fun1_t : public binary_function<T*, A, S> 270227825Stheraven{ 271227825Stheravenpublic: 272227825Stheraven explicit mem_fun1_t(S (T::*p)(A)); 273227825Stheraven S operator()(T* p, A x) const; 274227825Stheraven}; 275227825Stheraven 276227825Stheraventemplate<class S, class T> mem_fun_t<S,T> mem_fun(S (T::*f)()); 277227825Stheraventemplate<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A)); 278227825Stheraven 279227825Stheraventemplate<class S, class T> 280227825Stheravenclass mem_fun_ref_t : public unary_function<T, S> 281227825Stheraven{ 282227825Stheravenpublic: 283227825Stheraven explicit mem_fun_ref_t(S (T::*p)()); 284227825Stheraven S operator()(T& p) const; 285227825Stheraven}; 286227825Stheraven 287227825Stheraventemplate<class S, class T, class A> 288227825Stheravenclass mem_fun1_ref_t : public binary_function<T, A, S> 289227825Stheraven{ 290227825Stheravenpublic: 291227825Stheraven explicit mem_fun1_ref_t(S (T::*p)(A)); 292227825Stheraven S operator()(T& p, A x) const; 293227825Stheraven}; 294227825Stheraven 295227825Stheraventemplate<class S, class T> mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)()); 296227825Stheraventemplate<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A)); 297227825Stheraven 298227825Stheraventemplate <class S, class T> 299227825Stheravenclass const_mem_fun_t : public unary_function<const T*, S> 300227825Stheraven{ 301227825Stheravenpublic: 302227825Stheraven explicit const_mem_fun_t(S (T::*p)() const); 303227825Stheraven S operator()(const T* p) const; 304227825Stheraven}; 305227825Stheraven 306227825Stheraventemplate <class S, class T, class A> 307227825Stheravenclass const_mem_fun1_t : public binary_function<const T*, A, S> 308227825Stheraven{ 309227825Stheravenpublic: 310227825Stheraven explicit const_mem_fun1_t(S (T::*p)(A) const); 311227825Stheraven S operator()(const T* p, A x) const; 312227825Stheraven}; 313227825Stheraven 314227825Stheraventemplate <class S, class T> const_mem_fun_t<S,T> mem_fun(S (T::*f)() const); 315227825Stheraventemplate <class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const); 316227825Stheraven 317227825Stheraventemplate <class S, class T> 318227825Stheravenclass const_mem_fun_ref_t : public unary_function<T, S> 319227825Stheraven{ 320227825Stheravenpublic: 321227825Stheraven explicit const_mem_fun_ref_t(S (T::*p)() const); 322227825Stheraven S operator()(const T& p) const; 323227825Stheraven}; 324227825Stheraven 325227825Stheraventemplate <class S, class T, class A> 326227825Stheravenclass const_mem_fun1_ref_t : public binary_function<T, A, S> 327227825Stheraven{ 328227825Stheravenpublic: 329227825Stheraven explicit const_mem_fun1_ref_t(S (T::*p)(A) const); 330227825Stheraven S operator()(const T& p, A x) const; 331227825Stheraven}; 332227825Stheraven 333227825Stheraventemplate <class S, class T> const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const); 334227825Stheraventemplate <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const); 335227825Stheraven 336227825Stheraventemplate<class R, class T> unspecified mem_fn(R T::*); 337227825Stheraventemplate<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...)); 338227825Stheraventemplate<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const); 339227825Stheraventemplate<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) volatile); 340227825Stheraventemplate<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const volatile); 341227825Stheraventemplate<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) &); 342227825Stheraventemplate<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const &); 343227825Stheraventemplate<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) volatile &); 344227825Stheraventemplate<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const volatile &); 345227825Stheraventemplate<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) &&); 346227825Stheraventemplate<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const &&); 347227825Stheraventemplate<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) volatile &&); 348227825Stheraventemplate<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const volatile &&); 349227825Stheraven 350227825Stheravenclass bad_function_call 351227825Stheraven : public exception 352227825Stheraven{ 353227825Stheraven}; 354227825Stheraven 355227825Stheraventemplate<class> class function; // undefined 356227825Stheraven 357227825Stheraventemplate<class R, class... ArgTypes> 358227825Stheravenclass function<R(ArgTypes...)> 359227825Stheraven : public unary_function<T1, R> // iff sizeof...(ArgTypes) == 1 and 360227825Stheraven // ArgTypes contains T1 361227825Stheraven : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and 362227825Stheraven // ArgTypes contains T1 and T2 363227825Stheraven{ 364227825Stheravenpublic: 365227825Stheraven typedef R result_type; 366227825Stheraven 367227825Stheraven // construct/copy/destroy: 368227825Stheraven function() noexcept; 369227825Stheraven function(nullptr_t) noexcept; 370227825Stheraven function(const function&); 371227825Stheraven function(function&&) noexcept; 372227825Stheraven template<class F> 373227825Stheraven function(F); 374227825Stheraven template<Allocator Alloc> 375227825Stheraven function(allocator_arg_t, const Alloc&) noexcept; 376227825Stheraven template<Allocator Alloc> 377227825Stheraven function(allocator_arg_t, const Alloc&, nullptr_t) noexcept; 378227825Stheraven template<Allocator Alloc> 379227825Stheraven function(allocator_arg_t, const Alloc&, const function&); 380227825Stheraven template<Allocator Alloc> 381227825Stheraven function(allocator_arg_t, const Alloc&, function&&); 382227825Stheraven template<class F, Allocator Alloc> 383227825Stheraven function(allocator_arg_t, const Alloc&, F); 384227825Stheraven 385227825Stheraven function& operator=(const function&); 386227825Stheraven function& operator=(function&&) noexcept; 387227825Stheraven function& operator=(nullptr_t) noexcept; 388227825Stheraven template<class F> 389227825Stheraven function& operator=(F&&); 390227825Stheraven template<class F> 391227825Stheraven function& operator=(reference_wrapper<F>) noexcept; 392227825Stheraven 393227825Stheraven ~function(); 394227825Stheraven 395227825Stheraven // function modifiers: 396227825Stheraven void swap(function&) noexcept; 397227825Stheraven template<class F, class Alloc> 398227825Stheraven void assign(F&&, const Alloc&); 399227825Stheraven 400227825Stheraven // function capacity: 401227825Stheraven explicit operator bool() const noexcept; 402227825Stheraven 403227825Stheraven // function invocation: 404227825Stheraven R operator()(ArgTypes...) const; 405227825Stheraven 406227825Stheraven // function target access: 407227825Stheraven const std::type_info& target_type() const noexcept; 408227825Stheraven template <typename T> T* target() noexcept; 409227825Stheraven template <typename T> const T* target() const noexcept; 410227825Stheraven}; 411227825Stheraven 412227825Stheraven// Null pointer comparisons: 413227825Stheraventemplate <class R, class ... ArgTypes> 414227825Stheraven bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept; 415227825Stheraven 416227825Stheraventemplate <class R, class ... ArgTypes> 417227825Stheraven bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept; 418227825Stheraven 419227825Stheraventemplate <class R, class ... ArgTypes> 420227825Stheraven bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept; 421227825Stheraven 422227825Stheraventemplate <class R, class ... ArgTypes> 423227825Stheraven bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept; 424227825Stheraven 425227825Stheraven// specialized algorithms: 426227825Stheraventemplate <class R, class ... ArgTypes> 427227825Stheraven void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept; 428227825Stheraven 429227825Stheraventemplate <class T> struct hash; 430227825Stheraven 431227825Stheraventemplate <> struct hash<bool>; 432227825Stheraventemplate <> struct hash<char>; 433227825Stheraventemplate <> struct hash<signed char>; 434227825Stheraventemplate <> struct hash<unsigned char>; 435227825Stheraventemplate <> struct hash<char16_t>; 436227825Stheraventemplate <> struct hash<char32_t>; 437227825Stheraventemplate <> struct hash<wchar_t>; 438227825Stheraventemplate <> struct hash<short>; 439227825Stheraventemplate <> struct hash<unsigned short>; 440227825Stheraventemplate <> struct hash<int>; 441227825Stheraventemplate <> struct hash<unsigned int>; 442227825Stheraventemplate <> struct hash<long>; 443227825Stheraventemplate <> struct hash<long long>; 444227825Stheraventemplate <> struct hash<unsigned long>; 445227825Stheraventemplate <> struct hash<unsigned long long>; 446227825Stheraven 447227825Stheraventemplate <> struct hash<float>; 448227825Stheraventemplate <> struct hash<double>; 449227825Stheraventemplate <> struct hash<long double>; 450227825Stheraven 451227825Stheraventemplate<class T> struct hash<T*>; 452227825Stheraven 453227825Stheraven} // std 454227825Stheraven 455227825StheravenPOLICY: For non-variadic implementations, the number of arguments is limited 456227825Stheraven to 3. It is hoped that the need for non-variadic implementations 457227825Stheraven will be minimal. 458227825Stheraven 459227825Stheraven*/ 460227825Stheraven 461227825Stheraven#include <__config> 462227825Stheraven#include <type_traits> 463227825Stheraven#include <typeinfo> 464227825Stheraven#include <exception> 465227825Stheraven#include <memory> 466227825Stheraven#include <tuple> 467227825Stheraven 468227825Stheraven#include <__functional_base> 469227825Stheraven 470227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 471227825Stheraven#pragma GCC system_header 472227825Stheraven#endif 473227825Stheraven 474227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD 475227825Stheraven 476227825Stheraventemplate <class _Tp> 477227825Stheravenstruct _LIBCPP_VISIBLE plus : binary_function<_Tp, _Tp, _Tp> 478227825Stheraven{ 479227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const 480227825Stheraven {return __x + __y;} 481227825Stheraven}; 482227825Stheraven 483227825Stheraventemplate <class _Tp> 484227825Stheravenstruct _LIBCPP_VISIBLE minus : binary_function<_Tp, _Tp, _Tp> 485227825Stheraven{ 486227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const 487227825Stheraven {return __x - __y;} 488227825Stheraven}; 489227825Stheraven 490227825Stheraventemplate <class _Tp> 491227825Stheravenstruct _LIBCPP_VISIBLE multiplies : binary_function<_Tp, _Tp, _Tp> 492227825Stheraven{ 493227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const 494227825Stheraven {return __x * __y;} 495227825Stheraven}; 496227825Stheraven 497227825Stheraventemplate <class _Tp> 498227825Stheravenstruct _LIBCPP_VISIBLE divides : binary_function<_Tp, _Tp, _Tp> 499227825Stheraven{ 500227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const 501227825Stheraven {return __x / __y;} 502227825Stheraven}; 503227825Stheraven 504227825Stheraventemplate <class _Tp> 505227825Stheravenstruct _LIBCPP_VISIBLE modulus : binary_function<_Tp, _Tp, _Tp> 506227825Stheraven{ 507227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const 508227825Stheraven {return __x % __y;} 509227825Stheraven}; 510227825Stheraven 511227825Stheraventemplate <class _Tp> 512227825Stheravenstruct _LIBCPP_VISIBLE negate : unary_function<_Tp, _Tp> 513227825Stheraven{ 514227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const 515227825Stheraven {return -__x;} 516227825Stheraven}; 517227825Stheraven 518227825Stheraventemplate <class _Tp> 519227825Stheravenstruct _LIBCPP_VISIBLE equal_to : binary_function<_Tp, _Tp, bool> 520227825Stheraven{ 521227825Stheraven _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const 522227825Stheraven {return __x == __y;} 523227825Stheraven}; 524227825Stheraven 525227825Stheraventemplate <class _Tp> 526227825Stheravenstruct _LIBCPP_VISIBLE not_equal_to : binary_function<_Tp, _Tp, bool> 527227825Stheraven{ 528227825Stheraven _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const 529227825Stheraven {return __x != __y;} 530227825Stheraven}; 531227825Stheraven 532227825Stheraventemplate <class _Tp> 533227825Stheravenstruct _LIBCPP_VISIBLE greater : binary_function<_Tp, _Tp, bool> 534227825Stheraven{ 535227825Stheraven _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const 536227825Stheraven {return __x > __y;} 537227825Stheraven}; 538227825Stheraven 539232924Stheraven// less in <__functional_base> 540227825Stheraven 541227825Stheraventemplate <class _Tp> 542227825Stheravenstruct _LIBCPP_VISIBLE greater_equal : binary_function<_Tp, _Tp, bool> 543227825Stheraven{ 544227825Stheraven _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const 545227825Stheraven {return __x >= __y;} 546227825Stheraven}; 547227825Stheraven 548227825Stheraventemplate <class _Tp> 549227825Stheravenstruct _LIBCPP_VISIBLE less_equal : binary_function<_Tp, _Tp, bool> 550227825Stheraven{ 551227825Stheraven _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const 552227825Stheraven {return __x <= __y;} 553227825Stheraven}; 554227825Stheraven 555227825Stheraventemplate <class _Tp> 556227825Stheravenstruct _LIBCPP_VISIBLE logical_and : binary_function<_Tp, _Tp, bool> 557227825Stheraven{ 558227825Stheraven _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const 559227825Stheraven {return __x && __y;} 560227825Stheraven}; 561227825Stheraven 562227825Stheraventemplate <class _Tp> 563227825Stheravenstruct _LIBCPP_VISIBLE logical_or : binary_function<_Tp, _Tp, bool> 564227825Stheraven{ 565227825Stheraven _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const 566227825Stheraven {return __x || __y;} 567227825Stheraven}; 568227825Stheraven 569227825Stheraventemplate <class _Tp> 570227825Stheravenstruct _LIBCPP_VISIBLE logical_not : unary_function<_Tp, bool> 571227825Stheraven{ 572227825Stheraven _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x) const 573227825Stheraven {return !__x;} 574227825Stheraven}; 575227825Stheraven 576227825Stheraventemplate <class _Tp> 577227825Stheravenstruct _LIBCPP_VISIBLE bit_and : binary_function<_Tp, _Tp, _Tp> 578227825Stheraven{ 579227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const 580227825Stheraven {return __x & __y;} 581227825Stheraven}; 582227825Stheraven 583227825Stheraventemplate <class _Tp> 584227825Stheravenstruct _LIBCPP_VISIBLE bit_or : binary_function<_Tp, _Tp, _Tp> 585227825Stheraven{ 586227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const 587227825Stheraven {return __x | __y;} 588227825Stheraven}; 589227825Stheraven 590227825Stheraventemplate <class _Tp> 591227825Stheravenstruct _LIBCPP_VISIBLE bit_xor : binary_function<_Tp, _Tp, _Tp> 592227825Stheraven{ 593227825Stheraven _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const 594227825Stheraven {return __x ^ __y;} 595227825Stheraven}; 596227825Stheraven 597227825Stheraventemplate <class _Predicate> 598227825Stheravenclass _LIBCPP_VISIBLE unary_negate 599227825Stheraven : public unary_function<typename _Predicate::argument_type, bool> 600227825Stheraven{ 601227825Stheraven _Predicate __pred_; 602227825Stheravenpublic: 603227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit unary_negate(const _Predicate& __pred) 604227825Stheraven : __pred_(__pred) {} 605227825Stheraven _LIBCPP_INLINE_VISIBILITY bool operator()(const typename _Predicate::argument_type& __x) const 606227825Stheraven {return !__pred_(__x);} 607227825Stheraven}; 608227825Stheraven 609227825Stheraventemplate <class _Predicate> 610227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 611227825Stheravenunary_negate<_Predicate> 612227825Stheravennot1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);} 613227825Stheraven 614227825Stheraventemplate <class _Predicate> 615227825Stheravenclass _LIBCPP_VISIBLE binary_negate 616227825Stheraven : public binary_function<typename _Predicate::first_argument_type, 617227825Stheraven typename _Predicate::second_argument_type, 618227825Stheraven bool> 619227825Stheraven{ 620227825Stheraven _Predicate __pred_; 621227825Stheravenpublic: 622227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit binary_negate(const _Predicate& __pred) 623227825Stheraven : __pred_(__pred) {} 624227825Stheraven _LIBCPP_INLINE_VISIBILITY bool operator()(const typename _Predicate::first_argument_type& __x, 625227825Stheraven const typename _Predicate::second_argument_type& __y) const 626227825Stheraven {return !__pred_(__x, __y);} 627227825Stheraven}; 628227825Stheraven 629227825Stheraventemplate <class _Predicate> 630227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 631227825Stheravenbinary_negate<_Predicate> 632227825Stheravennot2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);} 633227825Stheraven 634227825Stheraventemplate <class __Operation> 635227825Stheravenclass _LIBCPP_VISIBLE binder1st 636227825Stheraven : public unary_function<typename __Operation::second_argument_type, 637227825Stheraven typename __Operation::result_type> 638227825Stheraven{ 639227825Stheravenprotected: 640227825Stheraven __Operation op; 641227825Stheraven typename __Operation::first_argument_type value; 642227825Stheravenpublic: 643227825Stheraven _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x, 644227825Stheraven const typename __Operation::first_argument_type __y) 645227825Stheraven : op(__x), value(__y) {} 646227825Stheraven _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 647227825Stheraven (typename __Operation::second_argument_type& __x) const 648227825Stheraven {return op(value, __x);} 649227825Stheraven _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 650227825Stheraven (const typename __Operation::second_argument_type& __x) const 651227825Stheraven {return op(value, __x);} 652227825Stheraven}; 653227825Stheraven 654227825Stheraventemplate <class __Operation, class _Tp> 655227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 656227825Stheravenbinder1st<__Operation> 657227825Stheravenbind1st(const __Operation& __op, const _Tp& __x) 658227825Stheraven {return binder1st<__Operation>(__op, __x);} 659227825Stheraven 660227825Stheraventemplate <class __Operation> 661227825Stheravenclass _LIBCPP_VISIBLE binder2nd 662227825Stheraven : public unary_function<typename __Operation::first_argument_type, 663227825Stheraven typename __Operation::result_type> 664227825Stheraven{ 665227825Stheravenprotected: 666227825Stheraven __Operation op; 667227825Stheraven typename __Operation::second_argument_type value; 668227825Stheravenpublic: 669227825Stheraven _LIBCPP_INLINE_VISIBILITY 670227825Stheraven binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y) 671227825Stheraven : op(__x), value(__y) {} 672227825Stheraven _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 673227825Stheraven ( typename __Operation::first_argument_type& __x) const 674227825Stheraven {return op(__x, value);} 675227825Stheraven _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 676227825Stheraven (const typename __Operation::first_argument_type& __x) const 677227825Stheraven {return op(__x, value);} 678227825Stheraven}; 679227825Stheraven 680227825Stheraventemplate <class __Operation, class _Tp> 681227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 682227825Stheravenbinder2nd<__Operation> 683227825Stheravenbind2nd(const __Operation& __op, const _Tp& __x) 684227825Stheraven {return binder2nd<__Operation>(__op, __x);} 685227825Stheraven 686227825Stheraventemplate <class _Arg, class _Result> 687227825Stheravenclass _LIBCPP_VISIBLE pointer_to_unary_function 688227825Stheraven : public unary_function<_Arg, _Result> 689227825Stheraven{ 690227825Stheraven _Result (*__f_)(_Arg); 691227825Stheravenpublic: 692227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg)) 693227825Stheraven : __f_(__f) {} 694227825Stheraven _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const 695227825Stheraven {return __f_(__x);} 696227825Stheraven}; 697227825Stheraven 698227825Stheraventemplate <class _Arg, class _Result> 699227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 700227825Stheravenpointer_to_unary_function<_Arg,_Result> 701227825Stheravenptr_fun(_Result (*__f)(_Arg)) 702227825Stheraven {return pointer_to_unary_function<_Arg,_Result>(__f);} 703227825Stheraven 704227825Stheraventemplate <class _Arg1, class _Arg2, class _Result> 705227825Stheravenclass _LIBCPP_VISIBLE pointer_to_binary_function 706227825Stheraven : public binary_function<_Arg1, _Arg2, _Result> 707227825Stheraven{ 708227825Stheraven _Result (*__f_)(_Arg1, _Arg2); 709227825Stheravenpublic: 710227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2)) 711227825Stheraven : __f_(__f) {} 712227825Stheraven _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const 713227825Stheraven {return __f_(__x, __y);} 714227825Stheraven}; 715227825Stheraven 716227825Stheraventemplate <class _Arg1, class _Arg2, class _Result> 717227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 718227825Stheravenpointer_to_binary_function<_Arg1,_Arg2,_Result> 719227825Stheravenptr_fun(_Result (*__f)(_Arg1,_Arg2)) 720227825Stheraven {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);} 721227825Stheraven 722227825Stheraventemplate<class _Sp, class _Tp> 723227825Stheravenclass _LIBCPP_VISIBLE mem_fun_t : public unary_function<_Tp*, _Sp> 724227825Stheraven{ 725227825Stheraven _Sp (_Tp::*__p_)(); 726227825Stheravenpublic: 727227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)()) 728227825Stheraven : __p_(__p) {} 729227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const 730227825Stheraven {return (__p->*__p_)();} 731227825Stheraven}; 732227825Stheraven 733227825Stheraventemplate<class _Sp, class _Tp, class _Ap> 734227825Stheravenclass _LIBCPP_VISIBLE mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp> 735227825Stheraven{ 736227825Stheraven _Sp (_Tp::*__p_)(_Ap); 737227825Stheravenpublic: 738227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap)) 739227825Stheraven : __p_(__p) {} 740227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const 741227825Stheraven {return (__p->*__p_)(__x);} 742227825Stheraven}; 743227825Stheraven 744227825Stheraventemplate<class _Sp, class _Tp> 745227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 746227825Stheravenmem_fun_t<_Sp,_Tp> 747227825Stheravenmem_fun(_Sp (_Tp::*__f)()) 748227825Stheraven {return mem_fun_t<_Sp,_Tp>(__f);} 749227825Stheraven 750227825Stheraventemplate<class _Sp, class _Tp, class _Ap> 751227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 752227825Stheravenmem_fun1_t<_Sp,_Tp,_Ap> 753227825Stheravenmem_fun(_Sp (_Tp::*__f)(_Ap)) 754227825Stheraven {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);} 755227825Stheraven 756227825Stheraventemplate<class _Sp, class _Tp> 757227825Stheravenclass _LIBCPP_VISIBLE mem_fun_ref_t : public unary_function<_Tp, _Sp> 758227825Stheraven{ 759227825Stheraven _Sp (_Tp::*__p_)(); 760227825Stheravenpublic: 761227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)()) 762227825Stheraven : __p_(__p) {} 763227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const 764227825Stheraven {return (__p.*__p_)();} 765227825Stheraven}; 766227825Stheraven 767227825Stheraventemplate<class _Sp, class _Tp, class _Ap> 768227825Stheravenclass _LIBCPP_VISIBLE mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp> 769227825Stheraven{ 770227825Stheraven _Sp (_Tp::*__p_)(_Ap); 771227825Stheravenpublic: 772227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap)) 773227825Stheraven : __p_(__p) {} 774227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const 775227825Stheraven {return (__p.*__p_)(__x);} 776227825Stheraven}; 777227825Stheraven 778227825Stheraventemplate<class _Sp, class _Tp> 779227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 780227825Stheravenmem_fun_ref_t<_Sp,_Tp> 781227825Stheravenmem_fun_ref(_Sp (_Tp::*__f)()) 782227825Stheraven {return mem_fun_ref_t<_Sp,_Tp>(__f);} 783227825Stheraven 784227825Stheraventemplate<class _Sp, class _Tp, class _Ap> 785227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 786227825Stheravenmem_fun1_ref_t<_Sp,_Tp,_Ap> 787227825Stheravenmem_fun_ref(_Sp (_Tp::*__f)(_Ap)) 788227825Stheraven {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} 789227825Stheraven 790227825Stheraventemplate <class _Sp, class _Tp> 791227825Stheravenclass _LIBCPP_VISIBLE const_mem_fun_t : public unary_function<const _Tp*, _Sp> 792227825Stheraven{ 793227825Stheraven _Sp (_Tp::*__p_)() const; 794227825Stheravenpublic: 795227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const) 796227825Stheraven : __p_(__p) {} 797227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const 798227825Stheraven {return (__p->*__p_)();} 799227825Stheraven}; 800227825Stheraven 801227825Stheraventemplate <class _Sp, class _Tp, class _Ap> 802227825Stheravenclass _LIBCPP_VISIBLE const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp> 803227825Stheraven{ 804227825Stheraven _Sp (_Tp::*__p_)(_Ap) const; 805227825Stheravenpublic: 806227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const) 807227825Stheraven : __p_(__p) {} 808227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const 809227825Stheraven {return (__p->*__p_)(__x);} 810227825Stheraven}; 811227825Stheraven 812227825Stheraventemplate <class _Sp, class _Tp> 813227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 814227825Stheravenconst_mem_fun_t<_Sp,_Tp> 815227825Stheravenmem_fun(_Sp (_Tp::*__f)() const) 816227825Stheraven {return const_mem_fun_t<_Sp,_Tp>(__f);} 817227825Stheraven 818227825Stheraventemplate <class _Sp, class _Tp, class _Ap> 819227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 820227825Stheravenconst_mem_fun1_t<_Sp,_Tp,_Ap> 821227825Stheravenmem_fun(_Sp (_Tp::*__f)(_Ap) const) 822227825Stheraven {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);} 823227825Stheraven 824227825Stheraventemplate <class _Sp, class _Tp> 825227825Stheravenclass _LIBCPP_VISIBLE const_mem_fun_ref_t : public unary_function<_Tp, _Sp> 826227825Stheraven{ 827227825Stheraven _Sp (_Tp::*__p_)() const; 828227825Stheravenpublic: 829227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const) 830227825Stheraven : __p_(__p) {} 831227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const 832227825Stheraven {return (__p.*__p_)();} 833227825Stheraven}; 834227825Stheraven 835227825Stheraventemplate <class _Sp, class _Tp, class _Ap> 836227825Stheravenclass _LIBCPP_VISIBLE const_mem_fun1_ref_t 837227825Stheraven : public binary_function<_Tp, _Ap, _Sp> 838227825Stheraven{ 839227825Stheraven _Sp (_Tp::*__p_)(_Ap) const; 840227825Stheravenpublic: 841227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const) 842227825Stheraven : __p_(__p) {} 843227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const 844227825Stheraven {return (__p.*__p_)(__x);} 845227825Stheraven}; 846227825Stheraven 847227825Stheraventemplate <class _Sp, class _Tp> 848227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 849227825Stheravenconst_mem_fun_ref_t<_Sp,_Tp> 850227825Stheravenmem_fun_ref(_Sp (_Tp::*__f)() const) 851227825Stheraven {return const_mem_fun_ref_t<_Sp,_Tp>(__f);} 852227825Stheraven 853227825Stheraventemplate <class _Sp, class _Tp, class _Ap> 854227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 855227825Stheravenconst_mem_fun1_ref_t<_Sp,_Tp,_Ap> 856227825Stheravenmem_fun_ref(_Sp (_Tp::*__f)(_Ap) const) 857227825Stheraven {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} 858227825Stheraven 859227825Stheraven#ifdef _LIBCPP_HAS_NO_VARIADICS 860227825Stheraven 861227825Stheraven#include <__functional_03> 862227825Stheraven 863227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 864227825Stheraven 865227825Stheraventemplate <class _Tp> 866227825Stheravenclass __mem_fn 867227825Stheraven : public __weak_result_type<_Tp> 868227825Stheraven{ 869227825Stheravenpublic: 870227825Stheraven // types 871227825Stheraven typedef _Tp type; 872227825Stheravenprivate: 873227825Stheraven type __f_; 874227825Stheraven 875227825Stheravenpublic: 876227825Stheraven _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {} 877227825Stheraven 878227825Stheraven // invoke 879227825Stheraven template <class... _ArgTypes> 880227825Stheraven _LIBCPP_INLINE_VISIBILITY 881227825Stheraven typename __invoke_return<type, _ArgTypes...>::type 882227825Stheraven operator() (_ArgTypes&&... __args) 883227825Stheraven { 884227825Stheraven return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...); 885227825Stheraven } 886227825Stheraven}; 887227825Stheraven 888232924Stheraventemplate<class _Rp, class _Tp> 889227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 890232924Stheraven__mem_fn<_Rp _Tp::*> 891232924Stheravenmem_fn(_Rp _Tp::* __pm) 892227825Stheraven{ 893232924Stheraven return __mem_fn<_Rp _Tp::*>(__pm); 894227825Stheraven} 895227825Stheraven 896232924Stheraventemplate<class _Rp, class _Tp, class ..._Args> 897227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 898232924Stheraven__mem_fn<_Rp (_Tp::*)(_Args...)> 899232924Stheravenmem_fn(_Rp (_Tp::* __pm)(_Args...)) 900227825Stheraven{ 901232924Stheraven return __mem_fn<_Rp (_Tp::*)(_Args...)>(__pm); 902227825Stheraven} 903227825Stheraven 904232924Stheraventemplate<class _Rp, class _Tp, class ..._Args> 905227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 906232924Stheraven__mem_fn<_Rp (_Tp::*)(_Args...) const> 907232924Stheravenmem_fn(_Rp (_Tp::* __pm)(_Args...) const) 908227825Stheraven{ 909232924Stheraven return __mem_fn<_Rp (_Tp::*)(_Args...) const>(__pm); 910227825Stheraven} 911227825Stheraven 912232924Stheraventemplate<class _Rp, class _Tp, class ..._Args> 913227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 914232924Stheraven__mem_fn<_Rp (_Tp::*)(_Args...) volatile> 915232924Stheravenmem_fn(_Rp (_Tp::* __pm)(_Args...) volatile) 916227825Stheraven{ 917232924Stheraven return __mem_fn<_Rp (_Tp::*)(_Args...) volatile>(__pm); 918227825Stheraven} 919227825Stheraven 920232924Stheraventemplate<class _Rp, class _Tp, class ..._Args> 921227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 922232924Stheraven__mem_fn<_Rp (_Tp::*)(_Args...) const volatile> 923232924Stheravenmem_fn(_Rp (_Tp::* __pm)(_Args...) const volatile) 924227825Stheraven{ 925232924Stheraven return __mem_fn<_Rp (_Tp::*)(_Args...) const volatile>(__pm); 926227825Stheraven} 927227825Stheraven 928227825Stheraven// bad_function_call 929227825Stheraven 930227825Stheravenclass _LIBCPP_EXCEPTION_ABI bad_function_call 931227825Stheraven : public exception 932227825Stheraven{ 933227825Stheraven}; 934227825Stheraven 935227825Stheraventemplate<class _Fp> class _LIBCPP_VISIBLE function; // undefined 936227825Stheraven 937227825Stheravennamespace __function 938227825Stheraven{ 939227825Stheraven 940232924Stheraventemplate<class _Rp, class ..._ArgTypes> 941227825Stheravenstruct __maybe_derive_from_unary_function 942227825Stheraven{ 943227825Stheraven}; 944227825Stheraven 945232924Stheraventemplate<class _Rp, class _A1> 946232924Stheravenstruct __maybe_derive_from_unary_function<_Rp(_A1)> 947232924Stheraven : public unary_function<_A1, _Rp> 948227825Stheraven{ 949227825Stheraven}; 950227825Stheraven 951232924Stheraventemplate<class _Rp, class ..._ArgTypes> 952227825Stheravenstruct __maybe_derive_from_binary_function 953227825Stheraven{ 954227825Stheraven}; 955227825Stheraven 956232924Stheraventemplate<class _Rp, class _A1, class _A2> 957232924Stheravenstruct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> 958232924Stheraven : public binary_function<_A1, _A2, _Rp> 959227825Stheraven{ 960227825Stheraven}; 961227825Stheraven 962227825Stheraventemplate<class _Fp> class __base; 963227825Stheraven 964232924Stheraventemplate<class _Rp, class ..._ArgTypes> 965232924Stheravenclass __base<_Rp(_ArgTypes...)> 966227825Stheraven{ 967227825Stheraven __base(const __base&); 968227825Stheraven __base& operator=(const __base&); 969227825Stheravenpublic: 970227825Stheraven _LIBCPP_INLINE_VISIBILITY __base() {} 971227825Stheraven _LIBCPP_INLINE_VISIBILITY virtual ~__base() {} 972227825Stheraven virtual __base* __clone() const = 0; 973227825Stheraven virtual void __clone(__base*) const = 0; 974227825Stheraven virtual void destroy() _NOEXCEPT = 0; 975227825Stheraven virtual void destroy_deallocate() _NOEXCEPT = 0; 976232924Stheraven virtual _Rp operator()(_ArgTypes&& ...) = 0; 977227825Stheraven#ifndef _LIBCPP_NO_RTTI 978227825Stheraven virtual const void* target(const type_info&) const _NOEXCEPT = 0; 979227825Stheraven virtual const std::type_info& target_type() const _NOEXCEPT = 0; 980227825Stheraven#endif // _LIBCPP_NO_RTTI 981227825Stheraven}; 982227825Stheraven 983227825Stheraventemplate<class _FD, class _Alloc, class _FB> class __func; 984227825Stheraven 985232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 986232924Stheravenclass __func<_Fp, _Alloc, _Rp(_ArgTypes...)> 987232924Stheraven : public __base<_Rp(_ArgTypes...)> 988227825Stheraven{ 989232924Stheraven __compressed_pair<_Fp, _Alloc> __f_; 990227825Stheravenpublic: 991227825Stheraven _LIBCPP_INLINE_VISIBILITY 992232924Stheraven explicit __func(_Fp&& __f) 993232924Stheraven : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), 994232924Stheraven _VSTD::forward_as_tuple()) {} 995227825Stheraven _LIBCPP_INLINE_VISIBILITY 996232924Stheraven explicit __func(const _Fp& __f, const _Alloc& __a) 997232924Stheraven : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), 998232924Stheraven _VSTD::forward_as_tuple(__a)) {} 999232924Stheraven 1000232924Stheraven _LIBCPP_INLINE_VISIBILITY 1001232924Stheraven explicit __func(const _Fp& __f, _Alloc&& __a) 1002232924Stheraven : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), 1003232924Stheraven _VSTD::forward_as_tuple(_VSTD::move(__a))) {} 1004232924Stheraven 1005232924Stheraven _LIBCPP_INLINE_VISIBILITY 1006232924Stheraven explicit __func(_Fp&& __f, _Alloc&& __a) 1007232924Stheraven : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), 1008232924Stheraven _VSTD::forward_as_tuple(_VSTD::move(__a))) {} 1009232924Stheraven virtual __base<_Rp(_ArgTypes...)>* __clone() const; 1010232924Stheraven virtual void __clone(__base<_Rp(_ArgTypes...)>*) const; 1011227825Stheraven virtual void destroy() _NOEXCEPT; 1012227825Stheraven virtual void destroy_deallocate() _NOEXCEPT; 1013232924Stheraven virtual _Rp operator()(_ArgTypes&& ... __arg); 1014227825Stheraven#ifndef _LIBCPP_NO_RTTI 1015227825Stheraven virtual const void* target(const type_info&) const _NOEXCEPT; 1016227825Stheraven virtual const std::type_info& target_type() const _NOEXCEPT; 1017227825Stheraven#endif // _LIBCPP_NO_RTTI 1018227825Stheraven}; 1019227825Stheraven 1020232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1021232924Stheraven__base<_Rp(_ArgTypes...)>* 1022232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const 1023227825Stheraven{ 1024232924Stheraven typedef typename _Alloc::template rebind<__func>::other _Ap; 1025232924Stheraven _Ap __a(__f_.second()); 1026232924Stheraven typedef __allocator_destructor<_Ap> _Dp; 1027232924Stheraven unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1028227825Stheraven ::new (__hold.get()) __func(__f_.first(), _Alloc(__a)); 1029227825Stheraven return __hold.release(); 1030227825Stheraven} 1031227825Stheraven 1032232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1033227825Stheravenvoid 1034232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const 1035227825Stheraven{ 1036227825Stheraven ::new (__p) __func(__f_.first(), __f_.second()); 1037227825Stheraven} 1038227825Stheraven 1039232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1040227825Stheravenvoid 1041232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT 1042227825Stheraven{ 1043232924Stheraven __f_.~__compressed_pair<_Fp, _Alloc>(); 1044227825Stheraven} 1045227825Stheraven 1046232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1047227825Stheravenvoid 1048232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT 1049227825Stheraven{ 1050232924Stheraven typedef typename _Alloc::template rebind<__func>::other _Ap; 1051232924Stheraven _Ap __a(__f_.second()); 1052232924Stheraven __f_.~__compressed_pair<_Fp, _Alloc>(); 1053227825Stheraven __a.deallocate(this, 1); 1054227825Stheraven} 1055227825Stheraven 1056232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1057232924Stheraven_Rp 1058232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg) 1059227825Stheraven{ 1060227825Stheraven return __invoke(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...); 1061227825Stheraven} 1062227825Stheraven 1063227825Stheraven#ifndef _LIBCPP_NO_RTTI 1064227825Stheraven 1065232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1066227825Stheravenconst void* 1067232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT 1068227825Stheraven{ 1069232924Stheraven if (__ti == typeid(_Fp)) 1070227825Stheraven return &__f_.first(); 1071227825Stheraven return (const void*)0; 1072227825Stheraven} 1073227825Stheraven 1074232924Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1075227825Stheravenconst std::type_info& 1076232924Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT 1077227825Stheraven{ 1078232924Stheraven return typeid(_Fp); 1079227825Stheraven} 1080227825Stheraven 1081227825Stheraven#endif // _LIBCPP_NO_RTTI 1082227825Stheraven 1083227825Stheraven} // __function 1084227825Stheraven 1085232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1086232924Stheravenclass _LIBCPP_VISIBLE function<_Rp(_ArgTypes...)> 1087232924Stheraven : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>, 1088232924Stheraven public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> 1089227825Stheraven{ 1090232924Stheraven typedef __function::__base<_Rp(_ArgTypes...)> __base; 1091246468Stheraven typename aligned_storage<3*sizeof(void*)>::type __buf_; 1092227825Stheraven __base* __f_; 1093227825Stheraven 1094232924Stheraven template <class _Fp> 1095227825Stheraven _LIBCPP_INLINE_VISIBILITY 1096232924Stheraven static bool __not_null(const _Fp&) {return true;} 1097232924Stheraven template <class _R2, class ..._Ap> 1098227825Stheraven _LIBCPP_INLINE_VISIBILITY 1099232924Stheraven static bool __not_null(_R2 (*__p)(_Ap...)) {return __p;} 1100232924Stheraven template <class _R2, class _Cp, class ..._Ap> 1101227825Stheraven _LIBCPP_INLINE_VISIBILITY 1102232924Stheraven static bool __not_null(_R2 (_Cp::*__p)(_Ap...)) {return __p;} 1103232924Stheraven template <class _R2, class _Cp, class ..._Ap> 1104227825Stheraven _LIBCPP_INLINE_VISIBILITY 1105232924Stheraven static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const) {return __p;} 1106232924Stheraven template <class _R2, class _Cp, class ..._Ap> 1107227825Stheraven _LIBCPP_INLINE_VISIBILITY 1108232924Stheraven static bool __not_null(_R2 (_Cp::*__p)(_Ap...) volatile) {return __p;} 1109232924Stheraven template <class _R2, class _Cp, class ..._Ap> 1110227825Stheraven _LIBCPP_INLINE_VISIBILITY 1111232924Stheraven static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const volatile) {return __p;} 1112232924Stheraven template <class _R2, class ..._Ap> 1113227825Stheraven _LIBCPP_INLINE_VISIBILITY 1114232924Stheraven static bool __not_null(const function<_Rp(_Ap...)>& __p) {return __p;} 1115227825Stheraven 1116241900Sdim template <class _Fp, bool = !is_same<_Fp, function>::value && 1117241900Sdim __invokable<_Fp&, _ArgTypes...>::value> 1118227825Stheraven struct __callable; 1119232924Stheraven template <class _Fp> 1120232924Stheraven struct __callable<_Fp, true> 1121227825Stheraven { 1122227825Stheraven static const bool value = 1123232924Stheraven is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type, 1124232924Stheraven _Rp>::value; 1125227825Stheraven }; 1126232924Stheraven template <class _Fp> 1127232924Stheraven struct __callable<_Fp, false> 1128227825Stheraven { 1129227825Stheraven static const bool value = false; 1130227825Stheraven }; 1131227825Stheravenpublic: 1132232924Stheraven typedef _Rp result_type; 1133227825Stheraven 1134227825Stheraven // construct/copy/destroy: 1135227825Stheraven _LIBCPP_INLINE_VISIBILITY 1136227825Stheraven function() _NOEXCEPT : __f_(0) {} 1137227825Stheraven _LIBCPP_INLINE_VISIBILITY 1138227825Stheraven function(nullptr_t) _NOEXCEPT : __f_(0) {} 1139227825Stheraven function(const function&); 1140227825Stheraven function(function&&) _NOEXCEPT; 1141232924Stheraven template<class _Fp> 1142232924Stheraven function(_Fp, 1143232924Stheraven typename enable_if<__callable<_Fp>::value>::type* = 0); 1144227825Stheraven 1145227825Stheraven template<class _Alloc> 1146227825Stheraven _LIBCPP_INLINE_VISIBILITY 1147227825Stheraven function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {} 1148227825Stheraven template<class _Alloc> 1149227825Stheraven _LIBCPP_INLINE_VISIBILITY 1150227825Stheraven function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {} 1151227825Stheraven template<class _Alloc> 1152227825Stheraven function(allocator_arg_t, const _Alloc&, const function&); 1153227825Stheraven template<class _Alloc> 1154227825Stheraven function(allocator_arg_t, const _Alloc&, function&&); 1155232924Stheraven template<class _Fp, class _Alloc> 1156232924Stheraven function(allocator_arg_t, const _Alloc& __a, _Fp __f, 1157232924Stheraven typename enable_if<__callable<_Fp>::value>::type* = 0); 1158227825Stheraven 1159227825Stheraven function& operator=(const function&); 1160227825Stheraven function& operator=(function&&) _NOEXCEPT; 1161227825Stheraven function& operator=(nullptr_t) _NOEXCEPT; 1162232924Stheraven template<class _Fp> 1163227825Stheraven typename enable_if 1164227825Stheraven < 1165232924Stheraven __callable<typename decay<_Fp>::type>::value, 1166227825Stheraven function& 1167227825Stheraven >::type 1168232924Stheraven operator=(_Fp&&); 1169227825Stheraven 1170227825Stheraven ~function(); 1171227825Stheraven 1172227825Stheraven // function modifiers: 1173227825Stheraven void swap(function&) _NOEXCEPT; 1174232924Stheraven template<class _Fp, class _Alloc> 1175227825Stheraven _LIBCPP_INLINE_VISIBILITY 1176232924Stheraven void assign(_Fp&& __f, const _Alloc& __a) 1177232924Stheraven {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);} 1178227825Stheraven 1179227825Stheraven // function capacity: 1180227825Stheraven _LIBCPP_INLINE_VISIBILITY 1181232924Stheraven _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;} 1182227825Stheraven 1183227825Stheraven // deleted overloads close possible hole in the type system 1184227825Stheraven template<class _R2, class... _ArgTypes2> 1185227825Stheraven bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete; 1186227825Stheraven template<class _R2, class... _ArgTypes2> 1187227825Stheraven bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete; 1188227825Stheravenpublic: 1189227825Stheraven // function invocation: 1190232924Stheraven _Rp operator()(_ArgTypes...) const; 1191227825Stheraven 1192227825Stheraven#ifndef _LIBCPP_NO_RTTI 1193227825Stheraven // function target access: 1194227825Stheraven const std::type_info& target_type() const _NOEXCEPT; 1195232924Stheraven template <typename _Tp> _Tp* target() _NOEXCEPT; 1196232924Stheraven template <typename _Tp> const _Tp* target() const _NOEXCEPT; 1197227825Stheraven#endif // _LIBCPP_NO_RTTI 1198227825Stheraven}; 1199227825Stheraven 1200232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1201232924Stheravenfunction<_Rp(_ArgTypes...)>::function(const function& __f) 1202227825Stheraven{ 1203227825Stheraven if (__f.__f_ == 0) 1204227825Stheraven __f_ = 0; 1205227825Stheraven else if (__f.__f_ == (const __base*)&__f.__buf_) 1206227825Stheraven { 1207227825Stheraven __f_ = (__base*)&__buf_; 1208227825Stheraven __f.__f_->__clone(__f_); 1209227825Stheraven } 1210227825Stheraven else 1211227825Stheraven __f_ = __f.__f_->__clone(); 1212227825Stheraven} 1213227825Stheraven 1214232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1215227825Stheraventemplate <class _Alloc> 1216232924Stheravenfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, 1217227825Stheraven const function& __f) 1218227825Stheraven{ 1219227825Stheraven if (__f.__f_ == 0) 1220227825Stheraven __f_ = 0; 1221227825Stheraven else if (__f.__f_ == (const __base*)&__f.__buf_) 1222227825Stheraven { 1223227825Stheraven __f_ = (__base*)&__buf_; 1224227825Stheraven __f.__f_->__clone(__f_); 1225227825Stheraven } 1226227825Stheraven else 1227227825Stheraven __f_ = __f.__f_->__clone(); 1228227825Stheraven} 1229227825Stheraven 1230232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1231232924Stheravenfunction<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT 1232227825Stheraven{ 1233227825Stheraven if (__f.__f_ == 0) 1234227825Stheraven __f_ = 0; 1235227825Stheraven else if (__f.__f_ == (__base*)&__f.__buf_) 1236227825Stheraven { 1237227825Stheraven __f_ = (__base*)&__buf_; 1238227825Stheraven __f.__f_->__clone(__f_); 1239227825Stheraven } 1240227825Stheraven else 1241227825Stheraven { 1242227825Stheraven __f_ = __f.__f_; 1243227825Stheraven __f.__f_ = 0; 1244227825Stheraven } 1245227825Stheraven} 1246227825Stheraven 1247232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1248227825Stheraventemplate <class _Alloc> 1249232924Stheravenfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, 1250227825Stheraven function&& __f) 1251227825Stheraven{ 1252227825Stheraven if (__f.__f_ == 0) 1253227825Stheraven __f_ = 0; 1254227825Stheraven else if (__f.__f_ == (__base*)&__f.__buf_) 1255227825Stheraven { 1256227825Stheraven __f_ = (__base*)&__buf_; 1257227825Stheraven __f.__f_->__clone(__f_); 1258227825Stheraven } 1259227825Stheraven else 1260227825Stheraven { 1261227825Stheraven __f_ = __f.__f_; 1262227825Stheraven __f.__f_ = 0; 1263227825Stheraven } 1264227825Stheraven} 1265227825Stheraven 1266232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1267232924Stheraventemplate <class _Fp> 1268232924Stheravenfunction<_Rp(_ArgTypes...)>::function(_Fp __f, 1269232924Stheraven typename enable_if<__callable<_Fp>::value>::type*) 1270227825Stheraven : __f_(0) 1271227825Stheraven{ 1272227825Stheraven if (__not_null(__f)) 1273227825Stheraven { 1274232924Stheraven typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF; 1275232924Stheraven if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) 1276227825Stheraven { 1277227825Stheraven __f_ = (__base*)&__buf_; 1278227825Stheraven ::new (__f_) _FF(_VSTD::move(__f)); 1279227825Stheraven } 1280227825Stheraven else 1281227825Stheraven { 1282232924Stheraven typedef allocator<_FF> _Ap; 1283232924Stheraven _Ap __a; 1284232924Stheraven typedef __allocator_destructor<_Ap> _Dp; 1285232924Stheraven unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1286232924Stheraven ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a)); 1287227825Stheraven __f_ = __hold.release(); 1288227825Stheraven } 1289227825Stheraven } 1290227825Stheraven} 1291227825Stheraven 1292232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1293232924Stheraventemplate <class _Fp, class _Alloc> 1294232924Stheravenfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, 1295232924Stheraven typename enable_if<__callable<_Fp>::value>::type*) 1296227825Stheraven : __f_(0) 1297227825Stheraven{ 1298227825Stheraven typedef allocator_traits<_Alloc> __alloc_traits; 1299227825Stheraven if (__not_null(__f)) 1300227825Stheraven { 1301232924Stheraven typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF; 1302232924Stheraven if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) 1303227825Stheraven { 1304227825Stheraven __f_ = (__base*)&__buf_; 1305227825Stheraven ::new (__f_) _FF(_VSTD::move(__f)); 1306227825Stheraven } 1307227825Stheraven else 1308227825Stheraven { 1309227825Stheraven typedef typename __alloc_traits::template 1310227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1311227825Stheraven rebind_alloc<_FF> 1312227825Stheraven#else 1313227825Stheraven rebind_alloc<_FF>::other 1314227825Stheraven#endif 1315232924Stheraven _Ap; 1316232924Stheraven _Ap __a(__a0); 1317232924Stheraven typedef __allocator_destructor<_Ap> _Dp; 1318232924Stheraven unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1319227825Stheraven ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a)); 1320227825Stheraven __f_ = __hold.release(); 1321227825Stheraven } 1322227825Stheraven } 1323227825Stheraven} 1324227825Stheraven 1325232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1326232924Stheravenfunction<_Rp(_ArgTypes...)>& 1327232924Stheravenfunction<_Rp(_ArgTypes...)>::operator=(const function& __f) 1328227825Stheraven{ 1329227825Stheraven function(__f).swap(*this); 1330227825Stheraven return *this; 1331227825Stheraven} 1332227825Stheraven 1333232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1334232924Stheravenfunction<_Rp(_ArgTypes...)>& 1335232924Stheravenfunction<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT 1336227825Stheraven{ 1337227825Stheraven if (__f_ == (__base*)&__buf_) 1338227825Stheraven __f_->destroy(); 1339227825Stheraven else if (__f_) 1340227825Stheraven __f_->destroy_deallocate(); 1341227825Stheraven __f_ = 0; 1342227825Stheraven if (__f.__f_ == 0) 1343227825Stheraven __f_ = 0; 1344227825Stheraven else if (__f.__f_ == (__base*)&__f.__buf_) 1345227825Stheraven { 1346227825Stheraven __f_ = (__base*)&__buf_; 1347227825Stheraven __f.__f_->__clone(__f_); 1348227825Stheraven } 1349227825Stheraven else 1350227825Stheraven { 1351227825Stheraven __f_ = __f.__f_; 1352227825Stheraven __f.__f_ = 0; 1353227825Stheraven } 1354241900Sdim return *this; 1355227825Stheraven} 1356227825Stheraven 1357232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1358232924Stheravenfunction<_Rp(_ArgTypes...)>& 1359232924Stheravenfunction<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT 1360227825Stheraven{ 1361227825Stheraven if (__f_ == (__base*)&__buf_) 1362227825Stheraven __f_->destroy(); 1363227825Stheraven else if (__f_) 1364227825Stheraven __f_->destroy_deallocate(); 1365227825Stheraven __f_ = 0; 1366241900Sdim return *this; 1367227825Stheraven} 1368227825Stheraven 1369232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1370232924Stheraventemplate <class _Fp> 1371227825Stheraventypename enable_if 1372227825Stheraven< 1373232924Stheraven function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value, 1374232924Stheraven function<_Rp(_ArgTypes...)>& 1375227825Stheraven>::type 1376232924Stheravenfunction<_Rp(_ArgTypes...)>::operator=(_Fp&& __f) 1377227825Stheraven{ 1378232924Stheraven function(_VSTD::forward<_Fp>(__f)).swap(*this); 1379227825Stheraven return *this; 1380227825Stheraven} 1381227825Stheraven 1382232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1383232924Stheravenfunction<_Rp(_ArgTypes...)>::~function() 1384227825Stheraven{ 1385227825Stheraven if (__f_ == (__base*)&__buf_) 1386227825Stheraven __f_->destroy(); 1387227825Stheraven else if (__f_) 1388227825Stheraven __f_->destroy_deallocate(); 1389227825Stheraven} 1390227825Stheraven 1391232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1392227825Stheravenvoid 1393232924Stheravenfunction<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT 1394227825Stheraven{ 1395227825Stheraven if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) 1396227825Stheraven { 1397227825Stheraven typename aligned_storage<sizeof(__buf_)>::type __tempbuf; 1398227825Stheraven __base* __t = (__base*)&__tempbuf; 1399227825Stheraven __f_->__clone(__t); 1400227825Stheraven __f_->destroy(); 1401227825Stheraven __f_ = 0; 1402227825Stheraven __f.__f_->__clone((__base*)&__buf_); 1403227825Stheraven __f.__f_->destroy(); 1404227825Stheraven __f.__f_ = 0; 1405227825Stheraven __f_ = (__base*)&__buf_; 1406227825Stheraven __t->__clone((__base*)&__f.__buf_); 1407227825Stheraven __t->destroy(); 1408227825Stheraven __f.__f_ = (__base*)&__f.__buf_; 1409227825Stheraven } 1410227825Stheraven else if (__f_ == (__base*)&__buf_) 1411227825Stheraven { 1412227825Stheraven __f_->__clone((__base*)&__f.__buf_); 1413227825Stheraven __f_->destroy(); 1414227825Stheraven __f_ = __f.__f_; 1415227825Stheraven __f.__f_ = (__base*)&__f.__buf_; 1416227825Stheraven } 1417227825Stheraven else if (__f.__f_ == (__base*)&__f.__buf_) 1418227825Stheraven { 1419227825Stheraven __f.__f_->__clone((__base*)&__buf_); 1420227825Stheraven __f.__f_->destroy(); 1421227825Stheraven __f.__f_ = __f_; 1422227825Stheraven __f_ = (__base*)&__buf_; 1423227825Stheraven } 1424227825Stheraven else 1425227825Stheraven _VSTD::swap(__f_, __f.__f_); 1426227825Stheraven} 1427227825Stheraven 1428232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1429232924Stheraven_Rp 1430232924Stheravenfunction<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const 1431227825Stheraven{ 1432227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 1433227825Stheraven if (__f_ == 0) 1434227825Stheraven throw bad_function_call(); 1435227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 1436227825Stheraven return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...); 1437227825Stheraven} 1438227825Stheraven 1439227825Stheraven#ifndef _LIBCPP_NO_RTTI 1440227825Stheraven 1441232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1442227825Stheravenconst std::type_info& 1443232924Stheravenfunction<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT 1444227825Stheraven{ 1445227825Stheraven if (__f_ == 0) 1446227825Stheraven return typeid(void); 1447227825Stheraven return __f_->target_type(); 1448227825Stheraven} 1449227825Stheraven 1450232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1451232924Stheraventemplate <typename _Tp> 1452232924Stheraven_Tp* 1453232924Stheravenfunction<_Rp(_ArgTypes...)>::target() _NOEXCEPT 1454227825Stheraven{ 1455227825Stheraven if (__f_ == 0) 1456232924Stheraven return (_Tp*)0; 1457232924Stheraven return (_Tp*)__f_->target(typeid(_Tp)); 1458227825Stheraven} 1459227825Stheraven 1460232924Stheraventemplate<class _Rp, class ..._ArgTypes> 1461232924Stheraventemplate <typename _Tp> 1462232924Stheravenconst _Tp* 1463232924Stheravenfunction<_Rp(_ArgTypes...)>::target() const _NOEXCEPT 1464227825Stheraven{ 1465227825Stheraven if (__f_ == 0) 1466232924Stheraven return (const _Tp*)0; 1467232924Stheraven return (const _Tp*)__f_->target(typeid(_Tp)); 1468227825Stheraven} 1469227825Stheraven 1470227825Stheraven#endif // _LIBCPP_NO_RTTI 1471227825Stheraven 1472232924Stheraventemplate <class _Rp, class... _ArgTypes> 1473227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1474227825Stheravenbool 1475232924Stheravenoperator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;} 1476227825Stheraven 1477232924Stheraventemplate <class _Rp, class... _ArgTypes> 1478227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1479227825Stheravenbool 1480232924Stheravenoperator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;} 1481227825Stheraven 1482232924Stheraventemplate <class _Rp, class... _ArgTypes> 1483227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1484227825Stheravenbool 1485232924Stheravenoperator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;} 1486227825Stheraven 1487232924Stheraventemplate <class _Rp, class... _ArgTypes> 1488227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1489227825Stheravenbool 1490232924Stheravenoperator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;} 1491227825Stheraven 1492232924Stheraventemplate <class _Rp, class... _ArgTypes> 1493227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1494227825Stheravenvoid 1495232924Stheravenswap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT 1496227825Stheraven{return __x.swap(__y);} 1497227825Stheraven 1498227825Stheraventemplate<class _Tp> struct __is_bind_expression : public false_type {}; 1499227825Stheraventemplate<class _Tp> struct _LIBCPP_VISIBLE is_bind_expression 1500227825Stheraven : public __is_bind_expression<typename remove_cv<_Tp>::type> {}; 1501227825Stheraven 1502227825Stheraventemplate<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {}; 1503227825Stheraventemplate<class _Tp> struct _LIBCPP_VISIBLE is_placeholder 1504227825Stheraven : public __is_placeholder<typename remove_cv<_Tp>::type> {}; 1505227825Stheraven 1506227825Stheravennamespace placeholders 1507227825Stheraven{ 1508227825Stheraven 1509232924Stheraventemplate <int _Np> struct __ph {}; 1510227825Stheraven 1511227825Stheravenextern __ph<1> _1; 1512227825Stheravenextern __ph<2> _2; 1513227825Stheravenextern __ph<3> _3; 1514227825Stheravenextern __ph<4> _4; 1515227825Stheravenextern __ph<5> _5; 1516227825Stheravenextern __ph<6> _6; 1517227825Stheravenextern __ph<7> _7; 1518227825Stheravenextern __ph<8> _8; 1519227825Stheravenextern __ph<9> _9; 1520227825Stheravenextern __ph<10> _10; 1521227825Stheraven 1522227825Stheraven} // placeholders 1523227825Stheraven 1524232924Stheraventemplate<int _Np> 1525232924Stheravenstruct __is_placeholder<placeholders::__ph<_Np> > 1526232924Stheraven : public integral_constant<int, _Np> {}; 1527227825Stheraven 1528227825Stheraventemplate <class _Tp, class _Uj> 1529227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1530227825Stheraven_Tp& 1531227825Stheraven__mu(reference_wrapper<_Tp> __t, _Uj&) 1532227825Stheraven{ 1533227825Stheraven return __t.get(); 1534227825Stheraven} 1535227825Stheraven 1536227825Stheraventemplate <class _Ti, class ..._Uj, size_t ..._Indx> 1537227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1538227825Stheraventypename __invoke_of<_Ti&, _Uj...>::type 1539227825Stheraven__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) 1540227825Stheraven{ 1541227825Stheraven return __ti(_VSTD::forward<_Uj>(get<_Indx>(__uj))...); 1542227825Stheraven} 1543227825Stheraven 1544227825Stheraventemplate <class _Ti, class ..._Uj> 1545227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1546227825Stheraventypename enable_if 1547227825Stheraven< 1548227825Stheraven is_bind_expression<_Ti>::value, 1549227825Stheraven typename __invoke_of<_Ti&, _Uj...>::type 1550227825Stheraven>::type 1551227825Stheraven__mu(_Ti& __ti, tuple<_Uj...>& __uj) 1552227825Stheraven{ 1553227825Stheraven typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices; 1554227825Stheraven return __mu_expand(__ti, __uj, __indices()); 1555227825Stheraven} 1556227825Stheraven 1557227825Stheraventemplate <bool IsPh, class _Ti, class _Uj> 1558227825Stheravenstruct __mu_return2 {}; 1559227825Stheraven 1560227825Stheraventemplate <class _Ti, class _Uj> 1561227825Stheravenstruct __mu_return2<true, _Ti, _Uj> 1562227825Stheraven{ 1563227825Stheraven typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type; 1564227825Stheraven}; 1565227825Stheraven 1566227825Stheraventemplate <class _Ti, class _Uj> 1567227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1568227825Stheraventypename enable_if 1569227825Stheraven< 1570227825Stheraven 0 < is_placeholder<_Ti>::value, 1571227825Stheraven typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type 1572227825Stheraven>::type 1573227825Stheraven__mu(_Ti&, _Uj& __uj) 1574227825Stheraven{ 1575227825Stheraven const size_t _Indx = is_placeholder<_Ti>::value - 1; 1576227825Stheraven return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(get<_Indx>(__uj)); 1577227825Stheraven} 1578227825Stheraven 1579227825Stheraventemplate <class _Ti, class _Uj> 1580227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1581227825Stheraventypename enable_if 1582227825Stheraven< 1583227825Stheraven !is_bind_expression<_Ti>::value && 1584227825Stheraven is_placeholder<_Ti>::value == 0 && 1585227825Stheraven !__is_reference_wrapper<_Ti>::value, 1586227825Stheraven _Ti& 1587227825Stheraven>::type 1588232924Stheraven__mu(_Ti& __ti, _Uj&) 1589227825Stheraven{ 1590227825Stheraven return __ti; 1591227825Stheraven} 1592227825Stheraven 1593227825Stheraventemplate <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh, 1594227825Stheraven class _TupleUj> 1595227825Stheravenstruct ____mu_return; 1596227825Stheraven 1597227825Stheraventemplate <class _Ti, class ..._Uj> 1598227825Stheravenstruct ____mu_return<_Ti, false, true, false, tuple<_Uj...> > 1599227825Stheraven{ 1600227825Stheraven typedef typename __invoke_of<_Ti&, _Uj...>::type type; 1601227825Stheraven}; 1602227825Stheraven 1603227825Stheraventemplate <class _Ti, class _TupleUj> 1604227825Stheravenstruct ____mu_return<_Ti, false, false, true, _TupleUj> 1605227825Stheraven{ 1606227825Stheraven typedef typename tuple_element<is_placeholder<_Ti>::value - 1, 1607227825Stheraven _TupleUj>::type&& type; 1608227825Stheraven}; 1609227825Stheraven 1610227825Stheraventemplate <class _Ti, class _TupleUj> 1611227825Stheravenstruct ____mu_return<_Ti, true, false, false, _TupleUj> 1612227825Stheraven{ 1613227825Stheraven typedef typename _Ti::type& type; 1614227825Stheraven}; 1615227825Stheraven 1616227825Stheraventemplate <class _Ti, class _TupleUj> 1617227825Stheravenstruct ____mu_return<_Ti, false, false, false, _TupleUj> 1618227825Stheraven{ 1619227825Stheraven typedef _Ti& type; 1620227825Stheraven}; 1621227825Stheraven 1622227825Stheraventemplate <class _Ti, class _TupleUj> 1623227825Stheravenstruct __mu_return 1624227825Stheraven : public ____mu_return<_Ti, 1625227825Stheraven __is_reference_wrapper<_Ti>::value, 1626227825Stheraven is_bind_expression<_Ti>::value, 1627227825Stheraven 0 < is_placeholder<_Ti>::value, 1628227825Stheraven _TupleUj> 1629227825Stheraven{ 1630227825Stheraven}; 1631227825Stheraven 1632232924Stheraventemplate <class _Fp, class _BoundArgs, class _TupleUj> 1633227825Stheravenstruct __bind_return; 1634227825Stheraven 1635232924Stheraventemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 1636232924Stheravenstruct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> 1637227825Stheraven{ 1638227825Stheraven typedef typename __invoke_of 1639227825Stheraven < 1640232924Stheraven _Fp&, 1641227825Stheraven typename __mu_return 1642227825Stheraven < 1643227825Stheraven _BoundArgs, 1644227825Stheraven _TupleUj 1645227825Stheraven >::type... 1646227825Stheraven >::type type; 1647227825Stheraven}; 1648227825Stheraven 1649232924Stheraventemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 1650232924Stheravenstruct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> 1651227825Stheraven{ 1652227825Stheraven typedef typename __invoke_of 1653227825Stheraven < 1654232924Stheraven _Fp&, 1655227825Stheraven typename __mu_return 1656227825Stheraven < 1657227825Stheraven const _BoundArgs, 1658227825Stheraven _TupleUj 1659227825Stheraven >::type... 1660227825Stheraven >::type type; 1661227825Stheraven}; 1662227825Stheraven 1663232924Stheraventemplate <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args> 1664227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1665232924Stheraventypename __bind_return<_Fp, _BoundArgs, _Args>::type 1666232924Stheraven__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, 1667227825Stheraven _Args&& __args) 1668227825Stheraven{ 1669227825Stheraven return __invoke(__f, __mu(get<_Indx>(__bound_args), __args)...); 1670227825Stheraven} 1671227825Stheraven 1672232924Stheraventemplate<class _Fp, class ..._BoundArgs> 1673227825Stheravenclass __bind 1674232924Stheraven : public __weak_result_type<typename decay<_Fp>::type> 1675227825Stheraven{ 1676232924Stheraven typedef typename decay<_Fp>::type _Fd; 1677227825Stheraven typedef tuple<typename decay<_BoundArgs>::type...> _Td; 1678227825Stheraven _Fd __f_; 1679227825Stheraven _Td __bound_args_; 1680227825Stheraven 1681227825Stheraven typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices; 1682227825Stheravenpublic: 1683227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 1684227825Stheraven 1685227825Stheraven _LIBCPP_INLINE_VISIBILITY 1686227825Stheraven __bind(const __bind& __b) 1687227825Stheraven : __f_(__b.__f_), 1688227825Stheraven __bound_args_(__b.__bound_args_) {} 1689227825Stheraven 1690227825Stheraven _LIBCPP_INLINE_VISIBILITY 1691227825Stheraven __bind& operator=(const __bind& __b) 1692227825Stheraven { 1693227825Stheraven __f_ = __b.__f_; 1694227825Stheraven __bound_args_ = __b.__bound_args_; 1695227825Stheraven return *this; 1696227825Stheraven } 1697227825Stheraven 1698227825Stheraven _LIBCPP_INLINE_VISIBILITY 1699227825Stheraven __bind(__bind&& __b) 1700227825Stheraven : __f_(_VSTD::move(__b.__f_)), 1701227825Stheraven __bound_args_(_VSTD::move(__b.__bound_args_)) {} 1702227825Stheraven 1703227825Stheraven _LIBCPP_INLINE_VISIBILITY 1704227825Stheraven __bind& operator=(__bind&& __b) 1705227825Stheraven { 1706227825Stheraven __f_ = _VSTD::move(__b.__f_); 1707227825Stheraven __bound_args_ = _VSTD::move(__b.__bound_args_); 1708227825Stheraven return *this; 1709227825Stheraven } 1710227825Stheraven 1711227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 1712227825Stheraven 1713241900Sdim template <class _Gp, class ..._BA, 1714241900Sdim class = typename enable_if 1715241900Sdim < 1716241900Sdim is_constructible<_Fd, _Gp>::value 1717241900Sdim >::type> 1718227825Stheraven _LIBCPP_INLINE_VISIBILITY 1719232924Stheraven explicit __bind(_Gp&& __f, _BA&& ...__bound_args) 1720232924Stheraven : __f_(_VSTD::forward<_Gp>(__f)), 1721227825Stheraven __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {} 1722227825Stheraven 1723227825Stheraven template <class ..._Args> 1724227825Stheraven _LIBCPP_INLINE_VISIBILITY 1725227825Stheraven typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type 1726227825Stheraven operator()(_Args&& ...__args) 1727227825Stheraven { 1728227825Stheraven return __apply_functor(__f_, __bound_args_, __indices(), 1729227825Stheraven tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); 1730227825Stheraven } 1731227825Stheraven 1732227825Stheraven template <class ..._Args> 1733227825Stheraven _LIBCPP_INLINE_VISIBILITY 1734227825Stheraven typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type 1735227825Stheraven operator()(_Args&& ...__args) const 1736227825Stheraven { 1737227825Stheraven return __apply_functor(__f_, __bound_args_, __indices(), 1738227825Stheraven tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); 1739227825Stheraven } 1740227825Stheraven}; 1741227825Stheraven 1742232924Stheraventemplate<class _Fp, class ..._BoundArgs> 1743232924Stheravenstruct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {}; 1744227825Stheraven 1745232924Stheraventemplate<class _Rp, class _Fp, class ..._BoundArgs> 1746227825Stheravenclass __bind_r 1747232924Stheraven : public __bind<_Fp, _BoundArgs...> 1748227825Stheraven{ 1749232924Stheraven typedef __bind<_Fp, _BoundArgs...> base; 1750227825Stheravenpublic: 1751232924Stheraven typedef _Rp result_type; 1752227825Stheraven 1753227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 1754227825Stheraven 1755227825Stheraven _LIBCPP_INLINE_VISIBILITY 1756227825Stheraven __bind_r(const __bind_r& __b) 1757227825Stheraven : base(_VSTD::forward<const base&>(__b)) {} 1758227825Stheraven 1759227825Stheraven _LIBCPP_INLINE_VISIBILITY 1760227825Stheraven __bind_r& operator=(const __bind_r& __b) 1761227825Stheraven { 1762227825Stheraven base::operator=(_VSTD::forward<const base&>(__b)); 1763227825Stheraven return *this; 1764227825Stheraven } 1765227825Stheraven 1766227825Stheraven _LIBCPP_INLINE_VISIBILITY 1767227825Stheraven __bind_r(__bind_r&& __b) 1768227825Stheraven : base(_VSTD::forward<base>(__b)) {} 1769227825Stheraven 1770227825Stheraven _LIBCPP_INLINE_VISIBILITY 1771227825Stheraven __bind_r& operator=(__bind_r&& __b) 1772227825Stheraven { 1773227825Stheraven base::operator=(_VSTD::forward<base>(__b)); 1774227825Stheraven return *this; 1775227825Stheraven } 1776227825Stheraven 1777227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 1778227825Stheraven 1779232924Stheraven template <class _Gp, class ..._BA> 1780227825Stheraven _LIBCPP_INLINE_VISIBILITY 1781232924Stheraven explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args) 1782232924Stheraven : base(_VSTD::forward<_Gp>(__f), 1783227825Stheraven _VSTD::forward<_BA>(__bound_args)...) {} 1784227825Stheraven 1785227825Stheraven template <class ..._Args> 1786227825Stheraven _LIBCPP_INLINE_VISIBILITY 1787227825Stheraven result_type 1788227825Stheraven operator()(_Args&& ...__args) 1789227825Stheraven { 1790227825Stheraven return base::operator()(_VSTD::forward<_Args>(__args)...); 1791227825Stheraven } 1792227825Stheraven 1793227825Stheraven template <class ..._Args> 1794227825Stheraven _LIBCPP_INLINE_VISIBILITY 1795227825Stheraven result_type 1796227825Stheraven operator()(_Args&& ...__args) const 1797227825Stheraven { 1798227825Stheraven return base::operator()(_VSTD::forward<_Args>(__args)...); 1799227825Stheraven } 1800227825Stheraven}; 1801227825Stheraven 1802232924Stheraventemplate<class _Rp, class _Fp, class ..._BoundArgs> 1803232924Stheravenstruct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; 1804227825Stheraven 1805232924Stheraventemplate<class _Fp, class ..._BoundArgs> 1806227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1807232924Stheraven__bind<_Fp, _BoundArgs...> 1808232924Stheravenbind(_Fp&& __f, _BoundArgs&&... __bound_args) 1809227825Stheraven{ 1810232924Stheraven typedef __bind<_Fp, _BoundArgs...> type; 1811232924Stheraven return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); 1812227825Stheraven} 1813227825Stheraven 1814232924Stheraventemplate<class _Rp, class _Fp, class ..._BoundArgs> 1815227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1816232924Stheraven__bind_r<_Rp, _Fp, _BoundArgs...> 1817232924Stheravenbind(_Fp&& __f, _BoundArgs&&... __bound_args) 1818227825Stheraven{ 1819232924Stheraven typedef __bind_r<_Rp, _Fp, _BoundArgs...> type; 1820232924Stheraven return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); 1821227825Stheraven} 1822227825Stheraven 1823227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 1824227825Stheraven 1825227825Stheraventemplate <> 1826227825Stheravenstruct _LIBCPP_VISIBLE hash<bool> 1827227825Stheraven : public unary_function<bool, size_t> 1828227825Stheraven{ 1829227825Stheraven _LIBCPP_INLINE_VISIBILITY 1830227825Stheraven size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1831227825Stheraven}; 1832227825Stheraven 1833227825Stheraventemplate <> 1834227825Stheravenstruct _LIBCPP_VISIBLE hash<char> 1835227825Stheraven : public unary_function<char, size_t> 1836227825Stheraven{ 1837227825Stheraven _LIBCPP_INLINE_VISIBILITY 1838227825Stheraven size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1839227825Stheraven}; 1840227825Stheraven 1841227825Stheraventemplate <> 1842227825Stheravenstruct _LIBCPP_VISIBLE hash<signed char> 1843227825Stheraven : public unary_function<signed char, size_t> 1844227825Stheraven{ 1845227825Stheraven _LIBCPP_INLINE_VISIBILITY 1846227825Stheraven size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1847227825Stheraven}; 1848227825Stheraven 1849227825Stheraventemplate <> 1850227825Stheravenstruct _LIBCPP_VISIBLE hash<unsigned char> 1851227825Stheraven : public unary_function<unsigned char, size_t> 1852227825Stheraven{ 1853227825Stheraven _LIBCPP_INLINE_VISIBILITY 1854227825Stheraven size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1855227825Stheraven}; 1856227825Stheraven 1857227825Stheraven#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 1858227825Stheraven 1859227825Stheraventemplate <> 1860227825Stheravenstruct _LIBCPP_VISIBLE hash<char16_t> 1861227825Stheraven : public unary_function<char16_t, size_t> 1862227825Stheraven{ 1863227825Stheraven _LIBCPP_INLINE_VISIBILITY 1864227825Stheraven size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1865227825Stheraven}; 1866227825Stheraven 1867227825Stheraventemplate <> 1868227825Stheravenstruct _LIBCPP_VISIBLE hash<char32_t> 1869227825Stheraven : public unary_function<char32_t, size_t> 1870227825Stheraven{ 1871227825Stheraven _LIBCPP_INLINE_VISIBILITY 1872227825Stheraven size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1873227825Stheraven}; 1874227825Stheraven 1875227825Stheraven#endif // _LIBCPP_HAS_NO_UNICODE_CHARS 1876227825Stheraven 1877227825Stheraventemplate <> 1878227825Stheravenstruct _LIBCPP_VISIBLE hash<wchar_t> 1879227825Stheraven : public unary_function<wchar_t, size_t> 1880227825Stheraven{ 1881227825Stheraven _LIBCPP_INLINE_VISIBILITY 1882227825Stheraven size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1883227825Stheraven}; 1884227825Stheraven 1885227825Stheraventemplate <> 1886227825Stheravenstruct _LIBCPP_VISIBLE hash<short> 1887227825Stheraven : public unary_function<short, size_t> 1888227825Stheraven{ 1889227825Stheraven _LIBCPP_INLINE_VISIBILITY 1890227825Stheraven size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1891227825Stheraven}; 1892227825Stheraven 1893227825Stheraventemplate <> 1894227825Stheravenstruct _LIBCPP_VISIBLE hash<unsigned short> 1895227825Stheraven : public unary_function<unsigned short, size_t> 1896227825Stheraven{ 1897227825Stheraven _LIBCPP_INLINE_VISIBILITY 1898227825Stheraven size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1899227825Stheraven}; 1900227825Stheraven 1901227825Stheraventemplate <> 1902227825Stheravenstruct _LIBCPP_VISIBLE hash<int> 1903227825Stheraven : public unary_function<int, size_t> 1904227825Stheraven{ 1905227825Stheraven _LIBCPP_INLINE_VISIBILITY 1906227825Stheraven size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1907227825Stheraven}; 1908227825Stheraven 1909227825Stheraventemplate <> 1910227825Stheravenstruct _LIBCPP_VISIBLE hash<unsigned int> 1911227825Stheraven : public unary_function<unsigned int, size_t> 1912227825Stheraven{ 1913227825Stheraven _LIBCPP_INLINE_VISIBILITY 1914227825Stheraven size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1915227825Stheraven}; 1916227825Stheraven 1917227825Stheraventemplate <> 1918227825Stheravenstruct _LIBCPP_VISIBLE hash<long> 1919227825Stheraven : public unary_function<long, size_t> 1920227825Stheraven{ 1921227825Stheraven _LIBCPP_INLINE_VISIBILITY 1922227825Stheraven size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1923227825Stheraven}; 1924227825Stheraven 1925227825Stheraventemplate <> 1926227825Stheravenstruct _LIBCPP_VISIBLE hash<unsigned long> 1927227825Stheraven : public unary_function<unsigned long, size_t> 1928227825Stheraven{ 1929227825Stheraven _LIBCPP_INLINE_VISIBILITY 1930227825Stheraven size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1931227825Stheraven}; 1932227825Stheraven 1933227825Stheraventemplate <> 1934227825Stheravenstruct _LIBCPP_VISIBLE hash<long long> 1935232924Stheraven : public __scalar_hash<long long> 1936227825Stheraven{ 1937227825Stheraven}; 1938227825Stheraven 1939227825Stheraventemplate <> 1940227825Stheravenstruct _LIBCPP_VISIBLE hash<unsigned long long> 1941232924Stheraven : public __scalar_hash<unsigned long long> 1942227825Stheraven{ 1943227825Stheraven}; 1944227825Stheraven 1945227825Stheraventemplate <> 1946227825Stheravenstruct _LIBCPP_VISIBLE hash<float> 1947232924Stheraven : public __scalar_hash<float> 1948227825Stheraven{ 1949227825Stheraven _LIBCPP_INLINE_VISIBILITY 1950227825Stheraven size_t operator()(float __v) const _NOEXCEPT 1951227825Stheraven { 1952232924Stheraven // -0.0 and 0.0 should return same hash 1953232924Stheraven if (__v == 0) 1954232924Stheraven return 0; 1955232924Stheraven return __scalar_hash<float>::operator()(__v); 1956227825Stheraven } 1957227825Stheraven}; 1958227825Stheraven 1959227825Stheraventemplate <> 1960227825Stheravenstruct _LIBCPP_VISIBLE hash<double> 1961232924Stheraven : public __scalar_hash<double> 1962227825Stheraven{ 1963227825Stheraven _LIBCPP_INLINE_VISIBILITY 1964227825Stheraven size_t operator()(double __v) const _NOEXCEPT 1965227825Stheraven { 1966232924Stheraven // -0.0 and 0.0 should return same hash 1967232924Stheraven if (__v == 0) 1968232924Stheraven return 0; 1969232924Stheraven return __scalar_hash<double>::operator()(__v); 1970227825Stheraven } 1971227825Stheraven}; 1972227825Stheraven 1973227825Stheraventemplate <> 1974227825Stheravenstruct _LIBCPP_VISIBLE hash<long double> 1975232924Stheraven : public __scalar_hash<long double> 1976227825Stheraven{ 1977227825Stheraven _LIBCPP_INLINE_VISIBILITY 1978227825Stheraven size_t operator()(long double __v) const _NOEXCEPT 1979227825Stheraven { 1980232924Stheraven // -0.0 and 0.0 should return same hash 1981227825Stheraven if (__v == 0) 1982227825Stheraven return 0; 1983232924Stheraven#if defined(__i386__) 1984232924Stheraven // Zero out padding bits 1985232924Stheraven union 1986232924Stheraven { 1987232924Stheraven long double __t; 1988232924Stheraven struct 1989232924Stheraven { 1990232924Stheraven size_t __a; 1991232924Stheraven size_t __b; 1992232924Stheraven size_t __c; 1993232924Stheraven size_t __d; 1994232924Stheraven }; 1995232924Stheraven } __u; 1996232924Stheraven __u.__a = 0; 1997232924Stheraven __u.__b = 0; 1998232924Stheraven __u.__c = 0; 1999232924Stheraven __u.__d = 0; 2000232924Stheraven __u.__t = __v; 2001232924Stheraven return __u.__a ^ __u.__b ^ __u.__c ^ __u.__d; 2002232924Stheraven#elif defined(__x86_64__) 2003232924Stheraven // Zero out padding bits 2004232924Stheraven union 2005232924Stheraven { 2006232924Stheraven long double __t; 2007232924Stheraven struct 2008232924Stheraven { 2009232924Stheraven size_t __a; 2010232924Stheraven size_t __b; 2011232924Stheraven }; 2012232924Stheraven } __u; 2013232924Stheraven __u.__a = 0; 2014232924Stheraven __u.__b = 0; 2015232924Stheraven __u.__t = __v; 2016232924Stheraven return __u.__a ^ __u.__b; 2017232924Stheraven#else 2018232924Stheraven return __scalar_hash<long double>::operator()(__v); 2019232924Stheraven#endif 2020227825Stheraven } 2021227825Stheraven}; 2022227825Stheraven 2023227825Stheraven// struct hash<T*> in <memory> 2024227825Stheraven 2025227825Stheraven_LIBCPP_END_NAMESPACE_STD 2026227825Stheraven 2027227825Stheraven#endif // _LIBCPP_FUNCTIONAL 2028