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> 59262801Sdim 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 71262801Sdimtemplate <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 77262801Sdimtemplate <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 83262801Sdimtemplate <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 89262801Sdimtemplate <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 95262801Sdimtemplate <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 101262801Sdimtemplate <class T> // <class T=void> in C++14 102227825Stheravenstruct negate : unary_function<T, T> 103227825Stheraven{ 104227825Stheraven T operator()(const T& x) const; 105227825Stheraven}; 106227825Stheraven 107262801Sdimtemplate <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 113262801Sdimtemplate <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 119262801Sdimtemplate <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 125262801Sdimtemplate <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 131262801Sdimtemplate <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 137262801Sdimtemplate <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 143262801Sdimtemplate <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 149262801Sdimtemplate <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 155262801Sdimtemplate <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 161262801Sdimtemplate <class T> // <class T=void> in C++14 162262801Sdimstruct bit_and : unary_function<T, bool> 163262801Sdim{ 164262801Sdim bool operator()(const T& x, const T& y) const; 165262801Sdim}; 166262801Sdim 167262801Sdimtemplate <class T> // <class T=void> in C++14 168262801Sdimstruct bit_or : unary_function<T, bool> 169262801Sdim{ 170262801Sdim bool operator()(const T& x, const T& y) const; 171262801Sdim}; 172262801Sdim 173262801Sdimtemplate <class T> // <class T=void> in C++14 174262801Sdimstruct bit_xor : unary_function<T, bool> 175262801Sdim{ 176262801Sdim bool operator()(const T& x, const T& y) const; 177262801Sdim}; 178262801Sdim 179262801Sdimtemplate <class T=void> // C++14 180262801Sdimstruct bit_xor : unary_function<T, bool> 181262801Sdim{ 182262801Sdim bool operator()(const T& x) const; 183262801Sdim}; 184262801Sdim 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 . 225232950Stheraven 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 488262801Sdim#if _LIBCPP_STD_VER > 11 489262801Sdimtemplate <class _Tp = void> 490262801Sdim#else 491227825Stheraventemplate <class _Tp> 492262801Sdim#endif 493262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY plus : binary_function<_Tp, _Tp, _Tp> 494227825Stheraven{ 495262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 496262801Sdim _Tp operator()(const _Tp& __x, const _Tp& __y) const 497227825Stheraven {return __x + __y;} 498227825Stheraven}; 499227825Stheraven 500262801Sdim#if _LIBCPP_STD_VER > 11 501262801Sdimtemplate <> 502262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY plus<void> 503262801Sdim{ 504262801Sdim template <class _T1, class _T2> 505262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 506262801Sdim auto operator()(_T1&& __t, _T2&& __u) const 507262801Sdim { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } 508262801Sdim typedef void is_transparent; 509262801Sdim}; 510262801Sdim#endif 511262801Sdim 512262801Sdim 513262801Sdim#if _LIBCPP_STD_VER > 11 514262801Sdimtemplate <class _Tp = void> 515262801Sdim#else 516227825Stheraventemplate <class _Tp> 517262801Sdim#endif 518262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY minus : binary_function<_Tp, _Tp, _Tp> 519227825Stheraven{ 520262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 521262801Sdim _Tp operator()(const _Tp& __x, const _Tp& __y) const 522227825Stheraven {return __x - __y;} 523227825Stheraven}; 524227825Stheraven 525262801Sdim#if _LIBCPP_STD_VER > 11 526262801Sdimtemplate <> 527262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY minus<void> 528262801Sdim{ 529262801Sdim template <class _T1, class _T2> 530262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 531262801Sdim auto operator()(_T1&& __t, _T2&& __u) const 532262801Sdim { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } 533262801Sdim typedef void is_transparent; 534262801Sdim}; 535262801Sdim#endif 536262801Sdim 537262801Sdim 538262801Sdim#if _LIBCPP_STD_VER > 11 539262801Sdimtemplate <class _Tp = void> 540262801Sdim#else 541227825Stheraventemplate <class _Tp> 542262801Sdim#endif 543262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY multiplies : binary_function<_Tp, _Tp, _Tp> 544227825Stheraven{ 545262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 546262801Sdim _Tp operator()(const _Tp& __x, const _Tp& __y) const 547227825Stheraven {return __x * __y;} 548227825Stheraven}; 549227825Stheraven 550262801Sdim#if _LIBCPP_STD_VER > 11 551262801Sdimtemplate <> 552262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY multiplies<void> 553262801Sdim{ 554262801Sdim template <class _T1, class _T2> 555262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 556262801Sdim auto operator()(_T1&& __t, _T2&& __u) const 557262801Sdim { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } 558262801Sdim typedef void is_transparent; 559262801Sdim}; 560262801Sdim#endif 561262801Sdim 562262801Sdim 563262801Sdim#if _LIBCPP_STD_VER > 11 564262801Sdimtemplate <class _Tp = void> 565262801Sdim#else 566227825Stheraventemplate <class _Tp> 567262801Sdim#endif 568262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY divides : binary_function<_Tp, _Tp, _Tp> 569227825Stheraven{ 570262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 571262801Sdim _Tp operator()(const _Tp& __x, const _Tp& __y) const 572227825Stheraven {return __x / __y;} 573227825Stheraven}; 574227825Stheraven 575262801Sdim#if _LIBCPP_STD_VER > 11 576262801Sdimtemplate <> 577262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY divides<void> 578262801Sdim{ 579262801Sdim template <class _T1, class _T2> 580262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 581262801Sdim auto operator()(_T1&& __t, _T2&& __u) const 582262801Sdim { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } 583262801Sdim typedef void is_transparent; 584262801Sdim}; 585262801Sdim#endif 586262801Sdim 587262801Sdim 588262801Sdim#if _LIBCPP_STD_VER > 11 589262801Sdimtemplate <class _Tp = void> 590262801Sdim#else 591227825Stheraventemplate <class _Tp> 592262801Sdim#endif 593262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY modulus : binary_function<_Tp, _Tp, _Tp> 594227825Stheraven{ 595262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 596262801Sdim _Tp operator()(const _Tp& __x, const _Tp& __y) const 597227825Stheraven {return __x % __y;} 598227825Stheraven}; 599227825Stheraven 600262801Sdim#if _LIBCPP_STD_VER > 11 601262801Sdimtemplate <> 602262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY modulus<void> 603262801Sdim{ 604262801Sdim template <class _T1, class _T2> 605262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 606262801Sdim auto operator()(_T1&& __t, _T2&& __u) const 607262801Sdim { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } 608262801Sdim typedef void is_transparent; 609262801Sdim}; 610262801Sdim#endif 611262801Sdim 612262801Sdim 613262801Sdim#if _LIBCPP_STD_VER > 11 614262801Sdimtemplate <class _Tp = void> 615262801Sdim#else 616227825Stheraventemplate <class _Tp> 617262801Sdim#endif 618262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY negate : unary_function<_Tp, _Tp> 619227825Stheraven{ 620262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 621262801Sdim _Tp operator()(const _Tp& __x) const 622227825Stheraven {return -__x;} 623227825Stheraven}; 624227825Stheraven 625262801Sdim#if _LIBCPP_STD_VER > 11 626262801Sdimtemplate <> 627262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY negate<void> 628262801Sdim{ 629262801Sdim template <class _Tp> 630262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 631262801Sdim auto operator()(_Tp&& __x) const 632262801Sdim { return -_VSTD::forward<_Tp>(__x); } 633262801Sdim typedef void is_transparent; 634262801Sdim}; 635262801Sdim#endif 636262801Sdim 637262801Sdim 638262801Sdim#if _LIBCPP_STD_VER > 11 639262801Sdimtemplate <class _Tp = void> 640262801Sdim#else 641227825Stheraventemplate <class _Tp> 642262801Sdim#endif 643262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY equal_to : binary_function<_Tp, _Tp, bool> 644227825Stheraven{ 645262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 646262801Sdim bool operator()(const _Tp& __x, const _Tp& __y) const 647227825Stheraven {return __x == __y;} 648227825Stheraven}; 649227825Stheraven 650262801Sdim#if _LIBCPP_STD_VER > 11 651262801Sdimtemplate <> 652262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY equal_to<void> 653262801Sdim{ 654262801Sdim template <class _T1, class _T2> 655262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 656262801Sdim auto operator()(_T1&& __t, _T2&& __u) const 657262801Sdim { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } 658262801Sdim typedef void is_transparent; 659262801Sdim}; 660262801Sdim#endif 661262801Sdim 662262801Sdim 663262801Sdim#if _LIBCPP_STD_VER > 11 664262801Sdimtemplate <class _Tp = void> 665262801Sdim#else 666227825Stheraventemplate <class _Tp> 667262801Sdim#endif 668262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY not_equal_to : binary_function<_Tp, _Tp, bool> 669227825Stheraven{ 670262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 671262801Sdim bool operator()(const _Tp& __x, const _Tp& __y) const 672227825Stheraven {return __x != __y;} 673227825Stheraven}; 674227825Stheraven 675262801Sdim#if _LIBCPP_STD_VER > 11 676262801Sdimtemplate <> 677262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY not_equal_to<void> 678262801Sdim{ 679262801Sdim template <class _T1, class _T2> 680262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 681262801Sdim auto operator()(_T1&& __t, _T2&& __u) const 682262801Sdim { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } 683262801Sdim typedef void is_transparent; 684262801Sdim}; 685262801Sdim#endif 686262801Sdim 687262801Sdim 688262801Sdim#if _LIBCPP_STD_VER > 11 689262801Sdimtemplate <class _Tp = void> 690262801Sdim#else 691227825Stheraventemplate <class _Tp> 692262801Sdim#endif 693262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY greater : binary_function<_Tp, _Tp, bool> 694227825Stheraven{ 695262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 696262801Sdim bool operator()(const _Tp& __x, const _Tp& __y) const 697227825Stheraven {return __x > __y;} 698227825Stheraven}; 699227825Stheraven 700262801Sdim#if _LIBCPP_STD_VER > 11 701262801Sdimtemplate <> 702262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY greater<void> 703262801Sdim{ 704262801Sdim template <class _T1, class _T2> 705262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 706262801Sdim auto operator()(_T1&& __t, _T2&& __u) const 707262801Sdim { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } 708262801Sdim typedef void is_transparent; 709262801Sdim}; 710262801Sdim#endif 711262801Sdim 712262801Sdim 713232950Stheraven// less in <__functional_base> 714227825Stheraven 715262801Sdim#if _LIBCPP_STD_VER > 11 716262801Sdimtemplate <class _Tp = void> 717262801Sdim#else 718227825Stheraventemplate <class _Tp> 719262801Sdim#endif 720262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY greater_equal : binary_function<_Tp, _Tp, bool> 721227825Stheraven{ 722262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 723262801Sdim bool operator()(const _Tp& __x, const _Tp& __y) const 724227825Stheraven {return __x >= __y;} 725227825Stheraven}; 726227825Stheraven 727262801Sdim#if _LIBCPP_STD_VER > 11 728262801Sdimtemplate <> 729262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY greater_equal<void> 730262801Sdim{ 731262801Sdim template <class _T1, class _T2> 732262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 733262801Sdim auto operator()(_T1&& __t, _T2&& __u) const 734262801Sdim { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } 735262801Sdim typedef void is_transparent; 736262801Sdim}; 737262801Sdim#endif 738262801Sdim 739262801Sdim 740262801Sdim#if _LIBCPP_STD_VER > 11 741262801Sdimtemplate <class _Tp = void> 742262801Sdim#else 743227825Stheraventemplate <class _Tp> 744262801Sdim#endif 745262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY less_equal : binary_function<_Tp, _Tp, bool> 746227825Stheraven{ 747262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 748262801Sdim bool operator()(const _Tp& __x, const _Tp& __y) const 749227825Stheraven {return __x <= __y;} 750227825Stheraven}; 751227825Stheraven 752262801Sdim#if _LIBCPP_STD_VER > 11 753262801Sdimtemplate <> 754262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY less_equal<void> 755262801Sdim{ 756262801Sdim template <class _T1, class _T2> 757262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 758262801Sdim auto operator()(_T1&& __t, _T2&& __u) const 759262801Sdim { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } 760262801Sdim typedef void is_transparent; 761262801Sdim}; 762262801Sdim#endif 763262801Sdim 764262801Sdim 765262801Sdim#if _LIBCPP_STD_VER > 11 766262801Sdimtemplate <class _Tp = void> 767262801Sdim#else 768227825Stheraventemplate <class _Tp> 769262801Sdim#endif 770262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_and : binary_function<_Tp, _Tp, bool> 771227825Stheraven{ 772262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 773262801Sdim bool operator()(const _Tp& __x, const _Tp& __y) const 774227825Stheraven {return __x && __y;} 775227825Stheraven}; 776227825Stheraven 777262801Sdim#if _LIBCPP_STD_VER > 11 778262801Sdimtemplate <> 779262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_and<void> 780262801Sdim{ 781262801Sdim template <class _T1, class _T2> 782262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 783262801Sdim auto operator()(_T1&& __t, _T2&& __u) const 784262801Sdim { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } 785262801Sdim typedef void is_transparent; 786262801Sdim}; 787262801Sdim#endif 788262801Sdim 789262801Sdim 790262801Sdim#if _LIBCPP_STD_VER > 11 791262801Sdimtemplate <class _Tp = void> 792262801Sdim#else 793227825Stheraventemplate <class _Tp> 794262801Sdim#endif 795262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_or : binary_function<_Tp, _Tp, bool> 796227825Stheraven{ 797262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 798262801Sdim bool operator()(const _Tp& __x, const _Tp& __y) const 799227825Stheraven {return __x || __y;} 800227825Stheraven}; 801227825Stheraven 802262801Sdim#if _LIBCPP_STD_VER > 11 803262801Sdimtemplate <> 804262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_or<void> 805262801Sdim{ 806262801Sdim template <class _T1, class _T2> 807262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 808262801Sdim auto operator()(_T1&& __t, _T2&& __u) const 809262801Sdim { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } 810262801Sdim typedef void is_transparent; 811262801Sdim}; 812262801Sdim#endif 813262801Sdim 814262801Sdim 815262801Sdim#if _LIBCPP_STD_VER > 11 816262801Sdimtemplate <class _Tp = void> 817262801Sdim#else 818227825Stheraventemplate <class _Tp> 819262801Sdim#endif 820262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_not : unary_function<_Tp, bool> 821227825Stheraven{ 822262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 823262801Sdim bool operator()(const _Tp& __x) const 824227825Stheraven {return !__x;} 825227825Stheraven}; 826227825Stheraven 827262801Sdim#if _LIBCPP_STD_VER > 11 828262801Sdimtemplate <> 829262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY logical_not<void> 830262801Sdim{ 831262801Sdim template <class _Tp> 832262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 833262801Sdim auto operator()(_Tp&& __x) const 834262801Sdim { return !_VSTD::forward<_Tp>(__x); } 835262801Sdim typedef void is_transparent; 836262801Sdim}; 837262801Sdim#endif 838262801Sdim 839262801Sdim 840262801Sdim#if _LIBCPP_STD_VER > 11 841262801Sdimtemplate <class _Tp = void> 842262801Sdim#else 843227825Stheraventemplate <class _Tp> 844262801Sdim#endif 845262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_and : binary_function<_Tp, _Tp, _Tp> 846227825Stheraven{ 847262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 848262801Sdim _Tp operator()(const _Tp& __x, const _Tp& __y) const 849227825Stheraven {return __x & __y;} 850227825Stheraven}; 851227825Stheraven 852262801Sdim#if _LIBCPP_STD_VER > 11 853262801Sdimtemplate <> 854262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_and<void> 855262801Sdim{ 856262801Sdim template <class _T1, class _T2> 857262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 858262801Sdim auto operator()(_T1&& __t, _T2&& __u) const 859262801Sdim { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } 860262801Sdim typedef void is_transparent; 861262801Sdim}; 862262801Sdim#endif 863262801Sdim 864262801Sdim 865262801Sdim#if _LIBCPP_STD_VER > 11 866262801Sdimtemplate <class _Tp = void> 867262801Sdim#else 868227825Stheraventemplate <class _Tp> 869262801Sdim#endif 870262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_or : binary_function<_Tp, _Tp, _Tp> 871227825Stheraven{ 872262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 873262801Sdim _Tp operator()(const _Tp& __x, const _Tp& __y) const 874227825Stheraven {return __x | __y;} 875227825Stheraven}; 876227825Stheraven 877262801Sdim#if _LIBCPP_STD_VER > 11 878262801Sdimtemplate <> 879262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_or<void> 880262801Sdim{ 881262801Sdim template <class _T1, class _T2> 882262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 883262801Sdim auto operator()(_T1&& __t, _T2&& __u) const 884262801Sdim { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } 885262801Sdim typedef void is_transparent; 886262801Sdim}; 887262801Sdim#endif 888262801Sdim 889262801Sdim 890262801Sdim#if _LIBCPP_STD_VER > 11 891262801Sdimtemplate <class _Tp = void> 892262801Sdim#else 893227825Stheraventemplate <class _Tp> 894262801Sdim#endif 895262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_xor : binary_function<_Tp, _Tp, _Tp> 896227825Stheraven{ 897262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 898262801Sdim _Tp operator()(const _Tp& __x, const _Tp& __y) const 899227825Stheraven {return __x ^ __y;} 900227825Stheraven}; 901227825Stheraven 902262801Sdim#if _LIBCPP_STD_VER > 11 903262801Sdimtemplate <> 904262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_xor<void> 905262801Sdim{ 906262801Sdim template <class _T1, class _T2> 907262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 908262801Sdim auto operator()(_T1&& __t, _T2&& __u) const 909262801Sdim { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } 910262801Sdim typedef void is_transparent; 911262801Sdim}; 912262801Sdim#endif 913262801Sdim 914262801Sdim 915262801Sdim#if _LIBCPP_STD_VER > 11 916262801Sdimtemplate <class _Tp = void> 917262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_not : unary_function<_Tp, _Tp> 918262801Sdim{ 919262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 920262801Sdim _Tp operator()(const _Tp& __x) const 921262801Sdim {return ~__x;} 922262801Sdim}; 923262801Sdim 924262801Sdimtemplate <> 925262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY bit_not<void> 926262801Sdim{ 927262801Sdim template <class _Tp> 928262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 929262801Sdim auto operator()(_Tp&& __x) const 930262801Sdim { return ~_VSTD::forward<_Tp>(__x); } 931262801Sdim typedef void is_transparent; 932262801Sdim}; 933262801Sdim#endif 934262801Sdim 935227825Stheraventemplate <class _Predicate> 936262801Sdimclass _LIBCPP_TYPE_VIS_ONLY unary_negate 937227825Stheraven : public unary_function<typename _Predicate::argument_type, bool> 938227825Stheraven{ 939227825Stheraven _Predicate __pred_; 940227825Stheravenpublic: 941262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 942262801Sdim explicit unary_negate(const _Predicate& __pred) 943227825Stheraven : __pred_(__pred) {} 944262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 945262801Sdim bool operator()(const typename _Predicate::argument_type& __x) const 946227825Stheraven {return !__pred_(__x);} 947227825Stheraven}; 948227825Stheraven 949227825Stheraventemplate <class _Predicate> 950262801Sdiminline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 951227825Stheravenunary_negate<_Predicate> 952227825Stheravennot1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);} 953227825Stheraven 954227825Stheraventemplate <class _Predicate> 955262801Sdimclass _LIBCPP_TYPE_VIS_ONLY binary_negate 956227825Stheraven : public binary_function<typename _Predicate::first_argument_type, 957227825Stheraven typename _Predicate::second_argument_type, 958227825Stheraven bool> 959227825Stheraven{ 960227825Stheraven _Predicate __pred_; 961227825Stheravenpublic: 962262801Sdim _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11 963262801Sdim binary_negate(const _Predicate& __pred) : __pred_(__pred) {} 964262801Sdim 965262801Sdim _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 966262801Sdim bool operator()(const typename _Predicate::first_argument_type& __x, 967227825Stheraven const typename _Predicate::second_argument_type& __y) const 968227825Stheraven {return !__pred_(__x, __y);} 969227825Stheraven}; 970227825Stheraven 971227825Stheraventemplate <class _Predicate> 972262801Sdiminline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 973227825Stheravenbinary_negate<_Predicate> 974227825Stheravennot2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);} 975227825Stheraven 976227825Stheraventemplate <class __Operation> 977262801Sdimclass _LIBCPP_TYPE_VIS_ONLY binder1st 978227825Stheraven : public unary_function<typename __Operation::second_argument_type, 979227825Stheraven typename __Operation::result_type> 980227825Stheraven{ 981227825Stheravenprotected: 982227825Stheraven __Operation op; 983227825Stheraven typename __Operation::first_argument_type value; 984227825Stheravenpublic: 985227825Stheraven _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x, 986227825Stheraven const typename __Operation::first_argument_type __y) 987227825Stheraven : op(__x), value(__y) {} 988227825Stheraven _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 989227825Stheraven (typename __Operation::second_argument_type& __x) const 990227825Stheraven {return op(value, __x);} 991227825Stheraven _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 992227825Stheraven (const typename __Operation::second_argument_type& __x) const 993227825Stheraven {return op(value, __x);} 994227825Stheraven}; 995227825Stheraven 996227825Stheraventemplate <class __Operation, class _Tp> 997227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 998227825Stheravenbinder1st<__Operation> 999227825Stheravenbind1st(const __Operation& __op, const _Tp& __x) 1000227825Stheraven {return binder1st<__Operation>(__op, __x);} 1001227825Stheraven 1002227825Stheraventemplate <class __Operation> 1003262801Sdimclass _LIBCPP_TYPE_VIS_ONLY binder2nd 1004227825Stheraven : public unary_function<typename __Operation::first_argument_type, 1005227825Stheraven typename __Operation::result_type> 1006227825Stheraven{ 1007227825Stheravenprotected: 1008227825Stheraven __Operation op; 1009227825Stheraven typename __Operation::second_argument_type value; 1010227825Stheravenpublic: 1011227825Stheraven _LIBCPP_INLINE_VISIBILITY 1012227825Stheraven binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y) 1013227825Stheraven : op(__x), value(__y) {} 1014227825Stheraven _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 1015227825Stheraven ( typename __Operation::first_argument_type& __x) const 1016227825Stheraven {return op(__x, value);} 1017227825Stheraven _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() 1018227825Stheraven (const typename __Operation::first_argument_type& __x) const 1019227825Stheraven {return op(__x, value);} 1020227825Stheraven}; 1021227825Stheraven 1022227825Stheraventemplate <class __Operation, class _Tp> 1023227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1024227825Stheravenbinder2nd<__Operation> 1025227825Stheravenbind2nd(const __Operation& __op, const _Tp& __x) 1026227825Stheraven {return binder2nd<__Operation>(__op, __x);} 1027227825Stheraven 1028227825Stheraventemplate <class _Arg, class _Result> 1029262801Sdimclass _LIBCPP_TYPE_VIS_ONLY pointer_to_unary_function 1030227825Stheraven : public unary_function<_Arg, _Result> 1031227825Stheraven{ 1032227825Stheraven _Result (*__f_)(_Arg); 1033227825Stheravenpublic: 1034227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg)) 1035227825Stheraven : __f_(__f) {} 1036227825Stheraven _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const 1037227825Stheraven {return __f_(__x);} 1038227825Stheraven}; 1039227825Stheraven 1040227825Stheraventemplate <class _Arg, class _Result> 1041227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1042227825Stheravenpointer_to_unary_function<_Arg,_Result> 1043227825Stheravenptr_fun(_Result (*__f)(_Arg)) 1044227825Stheraven {return pointer_to_unary_function<_Arg,_Result>(__f);} 1045227825Stheraven 1046227825Stheraventemplate <class _Arg1, class _Arg2, class _Result> 1047262801Sdimclass _LIBCPP_TYPE_VIS_ONLY pointer_to_binary_function 1048227825Stheraven : public binary_function<_Arg1, _Arg2, _Result> 1049227825Stheraven{ 1050227825Stheraven _Result (*__f_)(_Arg1, _Arg2); 1051227825Stheravenpublic: 1052227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2)) 1053227825Stheraven : __f_(__f) {} 1054227825Stheraven _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const 1055227825Stheraven {return __f_(__x, __y);} 1056227825Stheraven}; 1057227825Stheraven 1058227825Stheraventemplate <class _Arg1, class _Arg2, class _Result> 1059227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1060227825Stheravenpointer_to_binary_function<_Arg1,_Arg2,_Result> 1061227825Stheravenptr_fun(_Result (*__f)(_Arg1,_Arg2)) 1062227825Stheraven {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);} 1063227825Stheraven 1064227825Stheraventemplate<class _Sp, class _Tp> 1065262801Sdimclass _LIBCPP_TYPE_VIS_ONLY mem_fun_t : public unary_function<_Tp*, _Sp> 1066227825Stheraven{ 1067227825Stheraven _Sp (_Tp::*__p_)(); 1068227825Stheravenpublic: 1069227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)()) 1070227825Stheraven : __p_(__p) {} 1071227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const 1072227825Stheraven {return (__p->*__p_)();} 1073227825Stheraven}; 1074227825Stheraven 1075227825Stheraventemplate<class _Sp, class _Tp, class _Ap> 1076262801Sdimclass _LIBCPP_TYPE_VIS_ONLY mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp> 1077227825Stheraven{ 1078227825Stheraven _Sp (_Tp::*__p_)(_Ap); 1079227825Stheravenpublic: 1080227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap)) 1081227825Stheraven : __p_(__p) {} 1082227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const 1083227825Stheraven {return (__p->*__p_)(__x);} 1084227825Stheraven}; 1085227825Stheraven 1086227825Stheraventemplate<class _Sp, class _Tp> 1087227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1088227825Stheravenmem_fun_t<_Sp,_Tp> 1089227825Stheravenmem_fun(_Sp (_Tp::*__f)()) 1090227825Stheraven {return mem_fun_t<_Sp,_Tp>(__f);} 1091227825Stheraven 1092227825Stheraventemplate<class _Sp, class _Tp, class _Ap> 1093227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1094227825Stheravenmem_fun1_t<_Sp,_Tp,_Ap> 1095227825Stheravenmem_fun(_Sp (_Tp::*__f)(_Ap)) 1096227825Stheraven {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);} 1097227825Stheraven 1098227825Stheraventemplate<class _Sp, class _Tp> 1099262801Sdimclass _LIBCPP_TYPE_VIS_ONLY mem_fun_ref_t : public unary_function<_Tp, _Sp> 1100227825Stheraven{ 1101227825Stheraven _Sp (_Tp::*__p_)(); 1102227825Stheravenpublic: 1103227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)()) 1104227825Stheraven : __p_(__p) {} 1105227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const 1106227825Stheraven {return (__p.*__p_)();} 1107227825Stheraven}; 1108227825Stheraven 1109227825Stheraventemplate<class _Sp, class _Tp, class _Ap> 1110262801Sdimclass _LIBCPP_TYPE_VIS_ONLY mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp> 1111227825Stheraven{ 1112227825Stheraven _Sp (_Tp::*__p_)(_Ap); 1113227825Stheravenpublic: 1114227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap)) 1115227825Stheraven : __p_(__p) {} 1116227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const 1117227825Stheraven {return (__p.*__p_)(__x);} 1118227825Stheraven}; 1119227825Stheraven 1120227825Stheraventemplate<class _Sp, class _Tp> 1121227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1122227825Stheravenmem_fun_ref_t<_Sp,_Tp> 1123227825Stheravenmem_fun_ref(_Sp (_Tp::*__f)()) 1124227825Stheraven {return mem_fun_ref_t<_Sp,_Tp>(__f);} 1125227825Stheraven 1126227825Stheraventemplate<class _Sp, class _Tp, class _Ap> 1127227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1128227825Stheravenmem_fun1_ref_t<_Sp,_Tp,_Ap> 1129227825Stheravenmem_fun_ref(_Sp (_Tp::*__f)(_Ap)) 1130227825Stheraven {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} 1131227825Stheraven 1132227825Stheraventemplate <class _Sp, class _Tp> 1133262801Sdimclass _LIBCPP_TYPE_VIS_ONLY const_mem_fun_t : public unary_function<const _Tp*, _Sp> 1134227825Stheraven{ 1135227825Stheraven _Sp (_Tp::*__p_)() const; 1136227825Stheravenpublic: 1137227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const) 1138227825Stheraven : __p_(__p) {} 1139227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const 1140227825Stheraven {return (__p->*__p_)();} 1141227825Stheraven}; 1142227825Stheraven 1143227825Stheraventemplate <class _Sp, class _Tp, class _Ap> 1144262801Sdimclass _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp> 1145227825Stheraven{ 1146227825Stheraven _Sp (_Tp::*__p_)(_Ap) const; 1147227825Stheravenpublic: 1148227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const) 1149227825Stheraven : __p_(__p) {} 1150227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const 1151227825Stheraven {return (__p->*__p_)(__x);} 1152227825Stheraven}; 1153227825Stheraven 1154227825Stheraventemplate <class _Sp, class _Tp> 1155227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1156227825Stheravenconst_mem_fun_t<_Sp,_Tp> 1157227825Stheravenmem_fun(_Sp (_Tp::*__f)() const) 1158227825Stheraven {return const_mem_fun_t<_Sp,_Tp>(__f);} 1159227825Stheraven 1160227825Stheraventemplate <class _Sp, class _Tp, class _Ap> 1161227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1162227825Stheravenconst_mem_fun1_t<_Sp,_Tp,_Ap> 1163227825Stheravenmem_fun(_Sp (_Tp::*__f)(_Ap) const) 1164227825Stheraven {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);} 1165227825Stheraven 1166227825Stheraventemplate <class _Sp, class _Tp> 1167262801Sdimclass _LIBCPP_TYPE_VIS_ONLY const_mem_fun_ref_t : public unary_function<_Tp, _Sp> 1168227825Stheraven{ 1169227825Stheraven _Sp (_Tp::*__p_)() const; 1170227825Stheravenpublic: 1171227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const) 1172227825Stheraven : __p_(__p) {} 1173227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const 1174227825Stheraven {return (__p.*__p_)();} 1175227825Stheraven}; 1176227825Stheraven 1177227825Stheraventemplate <class _Sp, class _Tp, class _Ap> 1178262801Sdimclass _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_ref_t 1179227825Stheraven : public binary_function<_Tp, _Ap, _Sp> 1180227825Stheraven{ 1181227825Stheraven _Sp (_Tp::*__p_)(_Ap) const; 1182227825Stheravenpublic: 1183227825Stheraven _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const) 1184227825Stheraven : __p_(__p) {} 1185227825Stheraven _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const 1186227825Stheraven {return (__p.*__p_)(__x);} 1187227825Stheraven}; 1188227825Stheraven 1189227825Stheraventemplate <class _Sp, class _Tp> 1190227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1191227825Stheravenconst_mem_fun_ref_t<_Sp,_Tp> 1192227825Stheravenmem_fun_ref(_Sp (_Tp::*__f)() const) 1193227825Stheraven {return const_mem_fun_ref_t<_Sp,_Tp>(__f);} 1194227825Stheraven 1195227825Stheraventemplate <class _Sp, class _Tp, class _Ap> 1196227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1197227825Stheravenconst_mem_fun1_ref_t<_Sp,_Tp,_Ap> 1198227825Stheravenmem_fun_ref(_Sp (_Tp::*__f)(_Ap) const) 1199227825Stheraven {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} 1200227825Stheraven 1201227825Stheraven#ifdef _LIBCPP_HAS_NO_VARIADICS 1202227825Stheraven 1203227825Stheraven#include <__functional_03> 1204227825Stheraven 1205227825Stheraven#else // _LIBCPP_HAS_NO_VARIADICS 1206227825Stheraven 1207227825Stheraventemplate <class _Tp> 1208227825Stheravenclass __mem_fn 1209227825Stheraven : public __weak_result_type<_Tp> 1210227825Stheraven{ 1211227825Stheravenpublic: 1212227825Stheraven // types 1213227825Stheraven typedef _Tp type; 1214227825Stheravenprivate: 1215227825Stheraven type __f_; 1216227825Stheraven 1217227825Stheravenpublic: 1218227825Stheraven _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {} 1219227825Stheraven 1220227825Stheraven // invoke 1221227825Stheraven template <class... _ArgTypes> 1222227825Stheraven _LIBCPP_INLINE_VISIBILITY 1223227825Stheraven typename __invoke_return<type, _ArgTypes...>::type 1224262956Sdim operator() (_ArgTypes&&... __args) const 1225227825Stheraven { 1226227825Stheraven return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...); 1227227825Stheraven } 1228227825Stheraven}; 1229227825Stheraven 1230232950Stheraventemplate<class _Rp, class _Tp> 1231227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1232232950Stheraven__mem_fn<_Rp _Tp::*> 1233232950Stheravenmem_fn(_Rp _Tp::* __pm) 1234227825Stheraven{ 1235232950Stheraven return __mem_fn<_Rp _Tp::*>(__pm); 1236227825Stheraven} 1237227825Stheraven 1238227825Stheraven// bad_function_call 1239227825Stheraven 1240227825Stheravenclass _LIBCPP_EXCEPTION_ABI bad_function_call 1241227825Stheraven : public exception 1242227825Stheraven{ 1243227825Stheraven}; 1244227825Stheraven 1245262801Sdimtemplate<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined 1246227825Stheraven 1247227825Stheravennamespace __function 1248227825Stheraven{ 1249227825Stheraven 1250232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1251227825Stheravenstruct __maybe_derive_from_unary_function 1252227825Stheraven{ 1253227825Stheraven}; 1254227825Stheraven 1255232950Stheraventemplate<class _Rp, class _A1> 1256232950Stheravenstruct __maybe_derive_from_unary_function<_Rp(_A1)> 1257232950Stheraven : public unary_function<_A1, _Rp> 1258227825Stheraven{ 1259227825Stheraven}; 1260227825Stheraven 1261232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1262227825Stheravenstruct __maybe_derive_from_binary_function 1263227825Stheraven{ 1264227825Stheraven}; 1265227825Stheraven 1266232950Stheraventemplate<class _Rp, class _A1, class _A2> 1267232950Stheravenstruct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> 1268232950Stheraven : public binary_function<_A1, _A2, _Rp> 1269227825Stheraven{ 1270227825Stheraven}; 1271227825Stheraven 1272227825Stheraventemplate<class _Fp> class __base; 1273227825Stheraven 1274232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1275232950Stheravenclass __base<_Rp(_ArgTypes...)> 1276227825Stheraven{ 1277227825Stheraven __base(const __base&); 1278227825Stheraven __base& operator=(const __base&); 1279227825Stheravenpublic: 1280227825Stheraven _LIBCPP_INLINE_VISIBILITY __base() {} 1281227825Stheraven _LIBCPP_INLINE_VISIBILITY virtual ~__base() {} 1282227825Stheraven virtual __base* __clone() const = 0; 1283227825Stheraven virtual void __clone(__base*) const = 0; 1284227825Stheraven virtual void destroy() _NOEXCEPT = 0; 1285227825Stheraven virtual void destroy_deallocate() _NOEXCEPT = 0; 1286232950Stheraven virtual _Rp operator()(_ArgTypes&& ...) = 0; 1287227825Stheraven#ifndef _LIBCPP_NO_RTTI 1288227825Stheraven virtual const void* target(const type_info&) const _NOEXCEPT = 0; 1289227825Stheraven virtual const std::type_info& target_type() const _NOEXCEPT = 0; 1290227825Stheraven#endif // _LIBCPP_NO_RTTI 1291227825Stheraven}; 1292227825Stheraven 1293227825Stheraventemplate<class _FD, class _Alloc, class _FB> class __func; 1294227825Stheraven 1295232950Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1296232950Stheravenclass __func<_Fp, _Alloc, _Rp(_ArgTypes...)> 1297232950Stheraven : public __base<_Rp(_ArgTypes...)> 1298227825Stheraven{ 1299232950Stheraven __compressed_pair<_Fp, _Alloc> __f_; 1300227825Stheravenpublic: 1301227825Stheraven _LIBCPP_INLINE_VISIBILITY 1302232950Stheraven explicit __func(_Fp&& __f) 1303232950Stheraven : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), 1304232950Stheraven _VSTD::forward_as_tuple()) {} 1305227825Stheraven _LIBCPP_INLINE_VISIBILITY 1306232950Stheraven explicit __func(const _Fp& __f, const _Alloc& __a) 1307232950Stheraven : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), 1308232950Stheraven _VSTD::forward_as_tuple(__a)) {} 1309232950Stheraven 1310232950Stheraven _LIBCPP_INLINE_VISIBILITY 1311232950Stheraven explicit __func(const _Fp& __f, _Alloc&& __a) 1312232950Stheraven : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), 1313232950Stheraven _VSTD::forward_as_tuple(_VSTD::move(__a))) {} 1314232950Stheraven 1315232950Stheraven _LIBCPP_INLINE_VISIBILITY 1316232950Stheraven explicit __func(_Fp&& __f, _Alloc&& __a) 1317232950Stheraven : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), 1318232950Stheraven _VSTD::forward_as_tuple(_VSTD::move(__a))) {} 1319232950Stheraven virtual __base<_Rp(_ArgTypes...)>* __clone() const; 1320232950Stheraven virtual void __clone(__base<_Rp(_ArgTypes...)>*) const; 1321227825Stheraven virtual void destroy() _NOEXCEPT; 1322227825Stheraven virtual void destroy_deallocate() _NOEXCEPT; 1323232950Stheraven virtual _Rp operator()(_ArgTypes&& ... __arg); 1324227825Stheraven#ifndef _LIBCPP_NO_RTTI 1325227825Stheraven virtual const void* target(const type_info&) const _NOEXCEPT; 1326227825Stheraven virtual const std::type_info& target_type() const _NOEXCEPT; 1327227825Stheraven#endif // _LIBCPP_NO_RTTI 1328227825Stheraven}; 1329227825Stheraven 1330232950Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1331232950Stheraven__base<_Rp(_ArgTypes...)>* 1332232950Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const 1333227825Stheraven{ 1334232950Stheraven typedef typename _Alloc::template rebind<__func>::other _Ap; 1335232950Stheraven _Ap __a(__f_.second()); 1336232950Stheraven typedef __allocator_destructor<_Ap> _Dp; 1337232950Stheraven unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1338227825Stheraven ::new (__hold.get()) __func(__f_.first(), _Alloc(__a)); 1339227825Stheraven return __hold.release(); 1340227825Stheraven} 1341227825Stheraven 1342232950Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1343227825Stheravenvoid 1344232950Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const 1345227825Stheraven{ 1346227825Stheraven ::new (__p) __func(__f_.first(), __f_.second()); 1347227825Stheraven} 1348227825Stheraven 1349232950Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1350227825Stheravenvoid 1351232950Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT 1352227825Stheraven{ 1353232950Stheraven __f_.~__compressed_pair<_Fp, _Alloc>(); 1354227825Stheraven} 1355227825Stheraven 1356232950Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1357227825Stheravenvoid 1358232950Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT 1359227825Stheraven{ 1360232950Stheraven typedef typename _Alloc::template rebind<__func>::other _Ap; 1361232950Stheraven _Ap __a(__f_.second()); 1362232950Stheraven __f_.~__compressed_pair<_Fp, _Alloc>(); 1363227825Stheraven __a.deallocate(this, 1); 1364227825Stheraven} 1365227825Stheraven 1366232950Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1367232950Stheraven_Rp 1368232950Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg) 1369227825Stheraven{ 1370308143Sdim typedef __invoke_void_return_wrapper<_Rp> _Invoker; 1371308143Sdim return _Invoker::__call(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...); 1372227825Stheraven} 1373227825Stheraven 1374227825Stheraven#ifndef _LIBCPP_NO_RTTI 1375227825Stheraven 1376232950Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1377227825Stheravenconst void* 1378232950Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT 1379227825Stheraven{ 1380232950Stheraven if (__ti == typeid(_Fp)) 1381227825Stheraven return &__f_.first(); 1382227825Stheraven return (const void*)0; 1383227825Stheraven} 1384227825Stheraven 1385232950Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1386227825Stheravenconst std::type_info& 1387232950Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT 1388227825Stheraven{ 1389232950Stheraven return typeid(_Fp); 1390227825Stheraven} 1391227825Stheraven 1392227825Stheraven#endif // _LIBCPP_NO_RTTI 1393227825Stheraven 1394227825Stheraven} // __function 1395227825Stheraven 1396232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1397262801Sdimclass _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)> 1398232950Stheraven : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>, 1399232950Stheraven public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> 1400227825Stheraven{ 1401232950Stheraven typedef __function::__base<_Rp(_ArgTypes...)> __base; 1402246487Stheraven typename aligned_storage<3*sizeof(void*)>::type __buf_; 1403227825Stheraven __base* __f_; 1404227825Stheraven 1405232950Stheraven template <class _Fp> 1406227825Stheraven _LIBCPP_INLINE_VISIBILITY 1407232950Stheraven static bool __not_null(const _Fp&) {return true;} 1408232950Stheraven template <class _R2, class ..._Ap> 1409227825Stheraven _LIBCPP_INLINE_VISIBILITY 1410232950Stheraven static bool __not_null(_R2 (*__p)(_Ap...)) {return __p;} 1411232950Stheraven template <class _R2, class _Cp, class ..._Ap> 1412227825Stheraven _LIBCPP_INLINE_VISIBILITY 1413232950Stheraven static bool __not_null(_R2 (_Cp::*__p)(_Ap...)) {return __p;} 1414232950Stheraven template <class _R2, class _Cp, class ..._Ap> 1415227825Stheraven _LIBCPP_INLINE_VISIBILITY 1416232950Stheraven static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const) {return __p;} 1417232950Stheraven template <class _R2, class _Cp, class ..._Ap> 1418227825Stheraven _LIBCPP_INLINE_VISIBILITY 1419232950Stheraven static bool __not_null(_R2 (_Cp::*__p)(_Ap...) volatile) {return __p;} 1420232950Stheraven template <class _R2, class _Cp, class ..._Ap> 1421227825Stheraven _LIBCPP_INLINE_VISIBILITY 1422232950Stheraven static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const volatile) {return __p;} 1423232950Stheraven template <class _R2, class ..._Ap> 1424227825Stheraven _LIBCPP_INLINE_VISIBILITY 1425278724Sdim static bool __not_null(const function<_R2(_Ap...)>& __p) {return !!__p;} 1426227825Stheraven 1427241903Sdim template <class _Fp, bool = !is_same<_Fp, function>::value && 1428241903Sdim __invokable<_Fp&, _ArgTypes...>::value> 1429227825Stheraven struct __callable; 1430232950Stheraven template <class _Fp> 1431232950Stheraven struct __callable<_Fp, true> 1432227825Stheraven { 1433308143Sdim static const bool value = is_same<void, _Rp>::value || 1434232950Stheraven is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type, 1435232950Stheraven _Rp>::value; 1436227825Stheraven }; 1437232950Stheraven template <class _Fp> 1438232950Stheraven struct __callable<_Fp, false> 1439227825Stheraven { 1440227825Stheraven static const bool value = false; 1441227825Stheraven }; 1442227825Stheravenpublic: 1443232950Stheraven typedef _Rp result_type; 1444227825Stheraven 1445227825Stheraven // construct/copy/destroy: 1446227825Stheraven _LIBCPP_INLINE_VISIBILITY 1447227825Stheraven function() _NOEXCEPT : __f_(0) {} 1448227825Stheraven _LIBCPP_INLINE_VISIBILITY 1449227825Stheraven function(nullptr_t) _NOEXCEPT : __f_(0) {} 1450227825Stheraven function(const function&); 1451227825Stheraven function(function&&) _NOEXCEPT; 1452232950Stheraven template<class _Fp> 1453253159Stheraven function(_Fp, typename enable_if 1454253159Stheraven < 1455253159Stheraven __callable<_Fp>::value && 1456253159Stheraven !is_same<_Fp, function>::value 1457253159Stheraven >::type* = 0); 1458227825Stheraven 1459227825Stheraven template<class _Alloc> 1460227825Stheraven _LIBCPP_INLINE_VISIBILITY 1461227825Stheraven function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {} 1462227825Stheraven template<class _Alloc> 1463227825Stheraven _LIBCPP_INLINE_VISIBILITY 1464227825Stheraven function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {} 1465227825Stheraven template<class _Alloc> 1466227825Stheraven function(allocator_arg_t, const _Alloc&, const function&); 1467227825Stheraven template<class _Alloc> 1468227825Stheraven function(allocator_arg_t, const _Alloc&, function&&); 1469232950Stheraven template<class _Fp, class _Alloc> 1470232950Stheraven function(allocator_arg_t, const _Alloc& __a, _Fp __f, 1471232950Stheraven typename enable_if<__callable<_Fp>::value>::type* = 0); 1472227825Stheraven 1473227825Stheraven function& operator=(const function&); 1474227825Stheraven function& operator=(function&&) _NOEXCEPT; 1475227825Stheraven function& operator=(nullptr_t) _NOEXCEPT; 1476232950Stheraven template<class _Fp> 1477227825Stheraven typename enable_if 1478227825Stheraven < 1479253159Stheraven __callable<typename decay<_Fp>::type>::value && 1480253159Stheraven !is_same<typename remove_reference<_Fp>::type, function>::value, 1481227825Stheraven function& 1482227825Stheraven >::type 1483232950Stheraven operator=(_Fp&&); 1484227825Stheraven 1485227825Stheraven ~function(); 1486227825Stheraven 1487227825Stheraven // function modifiers: 1488227825Stheraven void swap(function&) _NOEXCEPT; 1489232950Stheraven template<class _Fp, class _Alloc> 1490227825Stheraven _LIBCPP_INLINE_VISIBILITY 1491232950Stheraven void assign(_Fp&& __f, const _Alloc& __a) 1492232950Stheraven {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);} 1493227825Stheraven 1494227825Stheraven // function capacity: 1495227825Stheraven _LIBCPP_INLINE_VISIBILITY 1496232950Stheraven _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;} 1497227825Stheraven 1498227825Stheraven // deleted overloads close possible hole in the type system 1499227825Stheraven template<class _R2, class... _ArgTypes2> 1500227825Stheraven bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete; 1501227825Stheraven template<class _R2, class... _ArgTypes2> 1502227825Stheraven bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete; 1503227825Stheravenpublic: 1504227825Stheraven // function invocation: 1505232950Stheraven _Rp operator()(_ArgTypes...) const; 1506227825Stheraven 1507227825Stheraven#ifndef _LIBCPP_NO_RTTI 1508227825Stheraven // function target access: 1509227825Stheraven const std::type_info& target_type() const _NOEXCEPT; 1510232950Stheraven template <typename _Tp> _Tp* target() _NOEXCEPT; 1511232950Stheraven template <typename _Tp> const _Tp* target() const _NOEXCEPT; 1512227825Stheraven#endif // _LIBCPP_NO_RTTI 1513227825Stheraven}; 1514227825Stheraven 1515232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1516232950Stheravenfunction<_Rp(_ArgTypes...)>::function(const function& __f) 1517227825Stheraven{ 1518227825Stheraven if (__f.__f_ == 0) 1519227825Stheraven __f_ = 0; 1520227825Stheraven else if (__f.__f_ == (const __base*)&__f.__buf_) 1521227825Stheraven { 1522227825Stheraven __f_ = (__base*)&__buf_; 1523227825Stheraven __f.__f_->__clone(__f_); 1524227825Stheraven } 1525227825Stheraven else 1526227825Stheraven __f_ = __f.__f_->__clone(); 1527227825Stheraven} 1528227825Stheraven 1529232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1530227825Stheraventemplate <class _Alloc> 1531232950Stheravenfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, 1532227825Stheraven const function& __f) 1533227825Stheraven{ 1534227825Stheraven if (__f.__f_ == 0) 1535227825Stheraven __f_ = 0; 1536227825Stheraven else if (__f.__f_ == (const __base*)&__f.__buf_) 1537227825Stheraven { 1538227825Stheraven __f_ = (__base*)&__buf_; 1539227825Stheraven __f.__f_->__clone(__f_); 1540227825Stheraven } 1541227825Stheraven else 1542227825Stheraven __f_ = __f.__f_->__clone(); 1543227825Stheraven} 1544227825Stheraven 1545232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1546232950Stheravenfunction<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT 1547227825Stheraven{ 1548227825Stheraven if (__f.__f_ == 0) 1549227825Stheraven __f_ = 0; 1550227825Stheraven else if (__f.__f_ == (__base*)&__f.__buf_) 1551227825Stheraven { 1552227825Stheraven __f_ = (__base*)&__buf_; 1553227825Stheraven __f.__f_->__clone(__f_); 1554227825Stheraven } 1555227825Stheraven else 1556227825Stheraven { 1557227825Stheraven __f_ = __f.__f_; 1558227825Stheraven __f.__f_ = 0; 1559227825Stheraven } 1560227825Stheraven} 1561227825Stheraven 1562232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1563227825Stheraventemplate <class _Alloc> 1564232950Stheravenfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, 1565227825Stheraven function&& __f) 1566227825Stheraven{ 1567227825Stheraven if (__f.__f_ == 0) 1568227825Stheraven __f_ = 0; 1569227825Stheraven else if (__f.__f_ == (__base*)&__f.__buf_) 1570227825Stheraven { 1571227825Stheraven __f_ = (__base*)&__buf_; 1572227825Stheraven __f.__f_->__clone(__f_); 1573227825Stheraven } 1574227825Stheraven else 1575227825Stheraven { 1576227825Stheraven __f_ = __f.__f_; 1577227825Stheraven __f.__f_ = 0; 1578227825Stheraven } 1579227825Stheraven} 1580227825Stheraven 1581232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1582232950Stheraventemplate <class _Fp> 1583232950Stheravenfunction<_Rp(_ArgTypes...)>::function(_Fp __f, 1584253159Stheraven typename enable_if 1585253159Stheraven < 1586253159Stheraven __callable<_Fp>::value && 1587253159Stheraven !is_same<_Fp, function>::value 1588253159Stheraven >::type*) 1589227825Stheraven : __f_(0) 1590227825Stheraven{ 1591227825Stheraven if (__not_null(__f)) 1592227825Stheraven { 1593232950Stheraven typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF; 1594232950Stheraven if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) 1595227825Stheraven { 1596227825Stheraven __f_ = (__base*)&__buf_; 1597227825Stheraven ::new (__f_) _FF(_VSTD::move(__f)); 1598227825Stheraven } 1599227825Stheraven else 1600227825Stheraven { 1601232950Stheraven typedef allocator<_FF> _Ap; 1602232950Stheraven _Ap __a; 1603232950Stheraven typedef __allocator_destructor<_Ap> _Dp; 1604232950Stheraven unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1605232950Stheraven ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a)); 1606227825Stheraven __f_ = __hold.release(); 1607227825Stheraven } 1608227825Stheraven } 1609227825Stheraven} 1610227825Stheraven 1611232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1612232950Stheraventemplate <class _Fp, class _Alloc> 1613232950Stheravenfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, 1614232950Stheraven typename enable_if<__callable<_Fp>::value>::type*) 1615227825Stheraven : __f_(0) 1616227825Stheraven{ 1617227825Stheraven typedef allocator_traits<_Alloc> __alloc_traits; 1618227825Stheraven if (__not_null(__f)) 1619227825Stheraven { 1620232950Stheraven typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF; 1621278724Sdim typedef typename __alloc_traits::template 1622278724Sdim#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1623278724Sdim rebind_alloc<_FF> 1624278724Sdim#else 1625278724Sdim rebind_alloc<_FF>::other 1626278724Sdim#endif 1627278724Sdim _Ap; 1628278724Sdim _Ap __a(__a0); 1629278724Sdim if (sizeof(_FF) <= sizeof(__buf_) && 1630278724Sdim is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value) 1631227825Stheraven { 1632227825Stheraven __f_ = (__base*)&__buf_; 1633278724Sdim ::new (__f_) _FF(_VSTD::move(__f), _Alloc(__a)); 1634227825Stheraven } 1635227825Stheraven else 1636227825Stheraven { 1637232950Stheraven typedef __allocator_destructor<_Ap> _Dp; 1638232950Stheraven unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1639227825Stheraven ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a)); 1640227825Stheraven __f_ = __hold.release(); 1641227825Stheraven } 1642227825Stheraven } 1643227825Stheraven} 1644227825Stheraven 1645232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1646232950Stheravenfunction<_Rp(_ArgTypes...)>& 1647232950Stheravenfunction<_Rp(_ArgTypes...)>::operator=(const function& __f) 1648227825Stheraven{ 1649227825Stheraven function(__f).swap(*this); 1650227825Stheraven return *this; 1651227825Stheraven} 1652227825Stheraven 1653232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1654232950Stheravenfunction<_Rp(_ArgTypes...)>& 1655232950Stheravenfunction<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT 1656227825Stheraven{ 1657227825Stheraven if (__f_ == (__base*)&__buf_) 1658227825Stheraven __f_->destroy(); 1659227825Stheraven else if (__f_) 1660227825Stheraven __f_->destroy_deallocate(); 1661227825Stheraven __f_ = 0; 1662227825Stheraven if (__f.__f_ == 0) 1663227825Stheraven __f_ = 0; 1664227825Stheraven else if (__f.__f_ == (__base*)&__f.__buf_) 1665227825Stheraven { 1666227825Stheraven __f_ = (__base*)&__buf_; 1667227825Stheraven __f.__f_->__clone(__f_); 1668227825Stheraven } 1669227825Stheraven else 1670227825Stheraven { 1671227825Stheraven __f_ = __f.__f_; 1672227825Stheraven __f.__f_ = 0; 1673227825Stheraven } 1674241903Sdim return *this; 1675227825Stheraven} 1676227825Stheraven 1677232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1678232950Stheravenfunction<_Rp(_ArgTypes...)>& 1679232950Stheravenfunction<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT 1680227825Stheraven{ 1681227825Stheraven if (__f_ == (__base*)&__buf_) 1682227825Stheraven __f_->destroy(); 1683227825Stheraven else if (__f_) 1684227825Stheraven __f_->destroy_deallocate(); 1685227825Stheraven __f_ = 0; 1686241903Sdim return *this; 1687227825Stheraven} 1688227825Stheraven 1689232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1690232950Stheraventemplate <class _Fp> 1691227825Stheraventypename enable_if 1692227825Stheraven< 1693253159Stheraven function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value && 1694253159Stheraven !is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value, 1695232950Stheraven function<_Rp(_ArgTypes...)>& 1696227825Stheraven>::type 1697232950Stheravenfunction<_Rp(_ArgTypes...)>::operator=(_Fp&& __f) 1698227825Stheraven{ 1699232950Stheraven function(_VSTD::forward<_Fp>(__f)).swap(*this); 1700227825Stheraven return *this; 1701227825Stheraven} 1702227825Stheraven 1703232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1704232950Stheravenfunction<_Rp(_ArgTypes...)>::~function() 1705227825Stheraven{ 1706227825Stheraven if (__f_ == (__base*)&__buf_) 1707227825Stheraven __f_->destroy(); 1708227825Stheraven else if (__f_) 1709227825Stheraven __f_->destroy_deallocate(); 1710227825Stheraven} 1711227825Stheraven 1712232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1713227825Stheravenvoid 1714232950Stheravenfunction<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT 1715227825Stheraven{ 1716227825Stheraven if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) 1717227825Stheraven { 1718227825Stheraven typename aligned_storage<sizeof(__buf_)>::type __tempbuf; 1719227825Stheraven __base* __t = (__base*)&__tempbuf; 1720227825Stheraven __f_->__clone(__t); 1721227825Stheraven __f_->destroy(); 1722227825Stheraven __f_ = 0; 1723227825Stheraven __f.__f_->__clone((__base*)&__buf_); 1724227825Stheraven __f.__f_->destroy(); 1725227825Stheraven __f.__f_ = 0; 1726227825Stheraven __f_ = (__base*)&__buf_; 1727227825Stheraven __t->__clone((__base*)&__f.__buf_); 1728227825Stheraven __t->destroy(); 1729227825Stheraven __f.__f_ = (__base*)&__f.__buf_; 1730227825Stheraven } 1731227825Stheraven else if (__f_ == (__base*)&__buf_) 1732227825Stheraven { 1733227825Stheraven __f_->__clone((__base*)&__f.__buf_); 1734227825Stheraven __f_->destroy(); 1735227825Stheraven __f_ = __f.__f_; 1736227825Stheraven __f.__f_ = (__base*)&__f.__buf_; 1737227825Stheraven } 1738227825Stheraven else if (__f.__f_ == (__base*)&__f.__buf_) 1739227825Stheraven { 1740227825Stheraven __f.__f_->__clone((__base*)&__buf_); 1741227825Stheraven __f.__f_->destroy(); 1742227825Stheraven __f.__f_ = __f_; 1743227825Stheraven __f_ = (__base*)&__buf_; 1744227825Stheraven } 1745227825Stheraven else 1746227825Stheraven _VSTD::swap(__f_, __f.__f_); 1747227825Stheraven} 1748227825Stheraven 1749232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1750232950Stheraven_Rp 1751232950Stheravenfunction<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const 1752227825Stheraven{ 1753227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 1754227825Stheraven if (__f_ == 0) 1755227825Stheraven throw bad_function_call(); 1756227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 1757227825Stheraven return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...); 1758227825Stheraven} 1759227825Stheraven 1760227825Stheraven#ifndef _LIBCPP_NO_RTTI 1761227825Stheraven 1762232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1763227825Stheravenconst std::type_info& 1764232950Stheravenfunction<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT 1765227825Stheraven{ 1766227825Stheraven if (__f_ == 0) 1767227825Stheraven return typeid(void); 1768227825Stheraven return __f_->target_type(); 1769227825Stheraven} 1770227825Stheraven 1771232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1772232950Stheraventemplate <typename _Tp> 1773232950Stheraven_Tp* 1774232950Stheravenfunction<_Rp(_ArgTypes...)>::target() _NOEXCEPT 1775227825Stheraven{ 1776227825Stheraven if (__f_ == 0) 1777232950Stheraven return (_Tp*)0; 1778232950Stheraven return (_Tp*)__f_->target(typeid(_Tp)); 1779227825Stheraven} 1780227825Stheraven 1781232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1782232950Stheraventemplate <typename _Tp> 1783232950Stheravenconst _Tp* 1784232950Stheravenfunction<_Rp(_ArgTypes...)>::target() const _NOEXCEPT 1785227825Stheraven{ 1786227825Stheraven if (__f_ == 0) 1787232950Stheraven return (const _Tp*)0; 1788232950Stheraven return (const _Tp*)__f_->target(typeid(_Tp)); 1789227825Stheraven} 1790227825Stheraven 1791227825Stheraven#endif // _LIBCPP_NO_RTTI 1792227825Stheraven 1793232950Stheraventemplate <class _Rp, class... _ArgTypes> 1794227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1795227825Stheravenbool 1796232950Stheravenoperator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;} 1797227825Stheraven 1798232950Stheraventemplate <class _Rp, class... _ArgTypes> 1799227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1800227825Stheravenbool 1801232950Stheravenoperator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;} 1802227825Stheraven 1803232950Stheraventemplate <class _Rp, class... _ArgTypes> 1804227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1805227825Stheravenbool 1806232950Stheravenoperator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;} 1807227825Stheraven 1808232950Stheraventemplate <class _Rp, class... _ArgTypes> 1809227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1810227825Stheravenbool 1811232950Stheravenoperator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;} 1812227825Stheraven 1813232950Stheraventemplate <class _Rp, class... _ArgTypes> 1814227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1815227825Stheravenvoid 1816232950Stheravenswap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT 1817227825Stheraven{return __x.swap(__y);} 1818227825Stheraven 1819227825Stheraventemplate<class _Tp> struct __is_bind_expression : public false_type {}; 1820262801Sdimtemplate<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression 1821227825Stheraven : public __is_bind_expression<typename remove_cv<_Tp>::type> {}; 1822227825Stheraven 1823227825Stheraventemplate<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {}; 1824262801Sdimtemplate<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_placeholder 1825227825Stheraven : public __is_placeholder<typename remove_cv<_Tp>::type> {}; 1826227825Stheraven 1827227825Stheravennamespace placeholders 1828227825Stheraven{ 1829227825Stheraven 1830232950Stheraventemplate <int _Np> struct __ph {}; 1831227825Stheraven 1832262801Sdim_LIBCPP_FUNC_VIS extern __ph<1> _1; 1833262801Sdim_LIBCPP_FUNC_VIS extern __ph<2> _2; 1834262801Sdim_LIBCPP_FUNC_VIS extern __ph<3> _3; 1835262801Sdim_LIBCPP_FUNC_VIS extern __ph<4> _4; 1836262801Sdim_LIBCPP_FUNC_VIS extern __ph<5> _5; 1837262801Sdim_LIBCPP_FUNC_VIS extern __ph<6> _6; 1838262801Sdim_LIBCPP_FUNC_VIS extern __ph<7> _7; 1839262801Sdim_LIBCPP_FUNC_VIS extern __ph<8> _8; 1840262801Sdim_LIBCPP_FUNC_VIS extern __ph<9> _9; 1841262801Sdim_LIBCPP_FUNC_VIS extern __ph<10> _10; 1842227825Stheraven 1843227825Stheraven} // placeholders 1844227825Stheraven 1845232950Stheraventemplate<int _Np> 1846232950Stheravenstruct __is_placeholder<placeholders::__ph<_Np> > 1847232950Stheraven : public integral_constant<int, _Np> {}; 1848227825Stheraven 1849227825Stheraventemplate <class _Tp, class _Uj> 1850227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1851227825Stheraven_Tp& 1852227825Stheraven__mu(reference_wrapper<_Tp> __t, _Uj&) 1853227825Stheraven{ 1854227825Stheraven return __t.get(); 1855227825Stheraven} 1856227825Stheraven 1857227825Stheraventemplate <class _Ti, class ..._Uj, size_t ..._Indx> 1858227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1859227825Stheraventypename __invoke_of<_Ti&, _Uj...>::type 1860227825Stheraven__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) 1861227825Stheraven{ 1862278724Sdim return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...); 1863227825Stheraven} 1864227825Stheraven 1865227825Stheraventemplate <class _Ti, class ..._Uj> 1866227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1867278724Sdimtypename __lazy_enable_if 1868227825Stheraven< 1869227825Stheraven is_bind_expression<_Ti>::value, 1870278724Sdim __invoke_of<_Ti&, _Uj...> 1871227825Stheraven>::type 1872227825Stheraven__mu(_Ti& __ti, tuple<_Uj...>& __uj) 1873227825Stheraven{ 1874227825Stheraven typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices; 1875227825Stheraven return __mu_expand(__ti, __uj, __indices()); 1876227825Stheraven} 1877227825Stheraven 1878227825Stheraventemplate <bool IsPh, class _Ti, class _Uj> 1879227825Stheravenstruct __mu_return2 {}; 1880227825Stheraven 1881227825Stheraventemplate <class _Ti, class _Uj> 1882227825Stheravenstruct __mu_return2<true, _Ti, _Uj> 1883227825Stheraven{ 1884227825Stheraven typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type; 1885227825Stheraven}; 1886227825Stheraven 1887227825Stheraventemplate <class _Ti, class _Uj> 1888227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1889227825Stheraventypename enable_if 1890227825Stheraven< 1891227825Stheraven 0 < is_placeholder<_Ti>::value, 1892227825Stheraven typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type 1893227825Stheraven>::type 1894227825Stheraven__mu(_Ti&, _Uj& __uj) 1895227825Stheraven{ 1896227825Stheraven const size_t _Indx = is_placeholder<_Ti>::value - 1; 1897278724Sdim return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj)); 1898227825Stheraven} 1899227825Stheraven 1900227825Stheraventemplate <class _Ti, class _Uj> 1901227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1902227825Stheraventypename enable_if 1903227825Stheraven< 1904227825Stheraven !is_bind_expression<_Ti>::value && 1905227825Stheraven is_placeholder<_Ti>::value == 0 && 1906227825Stheraven !__is_reference_wrapper<_Ti>::value, 1907227825Stheraven _Ti& 1908227825Stheraven>::type 1909232950Stheraven__mu(_Ti& __ti, _Uj&) 1910227825Stheraven{ 1911227825Stheraven return __ti; 1912227825Stheraven} 1913227825Stheraven 1914227825Stheraventemplate <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh, 1915227825Stheraven class _TupleUj> 1916227825Stheravenstruct ____mu_return; 1917227825Stheraven 1918253159Stheraventemplate <bool _Invokable, class _Ti, class ..._Uj> 1919253159Stheravenstruct ____mu_return_invokable // false 1920253159Stheraven{ 1921253159Stheraven typedef __nat type; 1922253159Stheraven}; 1923253159Stheraven 1924227825Stheraventemplate <class _Ti, class ..._Uj> 1925253159Stheravenstruct ____mu_return_invokable<true, _Ti, _Uj...> 1926227825Stheraven{ 1927227825Stheraven typedef typename __invoke_of<_Ti&, _Uj...>::type type; 1928227825Stheraven}; 1929227825Stheraven 1930253159Stheraventemplate <class _Ti, class ..._Uj> 1931253159Stheravenstruct ____mu_return<_Ti, false, true, false, tuple<_Uj...> > 1932253159Stheraven : public ____mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...> 1933253159Stheraven{ 1934253159Stheraven}; 1935253159Stheraven 1936227825Stheraventemplate <class _Ti, class _TupleUj> 1937227825Stheravenstruct ____mu_return<_Ti, false, false, true, _TupleUj> 1938227825Stheraven{ 1939227825Stheraven typedef typename tuple_element<is_placeholder<_Ti>::value - 1, 1940227825Stheraven _TupleUj>::type&& type; 1941227825Stheraven}; 1942227825Stheraven 1943227825Stheraventemplate <class _Ti, class _TupleUj> 1944227825Stheravenstruct ____mu_return<_Ti, true, false, false, _TupleUj> 1945227825Stheraven{ 1946227825Stheraven typedef typename _Ti::type& type; 1947227825Stheraven}; 1948227825Stheraven 1949227825Stheraventemplate <class _Ti, class _TupleUj> 1950227825Stheravenstruct ____mu_return<_Ti, false, false, false, _TupleUj> 1951227825Stheraven{ 1952227825Stheraven typedef _Ti& type; 1953227825Stheraven}; 1954227825Stheraven 1955227825Stheraventemplate <class _Ti, class _TupleUj> 1956227825Stheravenstruct __mu_return 1957227825Stheraven : public ____mu_return<_Ti, 1958227825Stheraven __is_reference_wrapper<_Ti>::value, 1959227825Stheraven is_bind_expression<_Ti>::value, 1960249998Sdim 0 < is_placeholder<_Ti>::value && 1961249998Sdim is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value, 1962227825Stheraven _TupleUj> 1963227825Stheraven{ 1964227825Stheraven}; 1965227825Stheraven 1966232950Stheraventemplate <class _Fp, class _BoundArgs, class _TupleUj> 1967249998Sdimstruct _is_valid_bind_return 1968249998Sdim{ 1969249998Sdim static const bool value = false; 1970249998Sdim}; 1971249998Sdim 1972249998Sdimtemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 1973249998Sdimstruct _is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> 1974249998Sdim{ 1975249998Sdim static const bool value = __invokable<_Fp, 1976249998Sdim typename __mu_return<_BoundArgs, _TupleUj>::type...>::value; 1977249998Sdim}; 1978249998Sdim 1979249998Sdimtemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 1980249998Sdimstruct _is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> 1981249998Sdim{ 1982249998Sdim static const bool value = __invokable<_Fp, 1983249998Sdim typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value; 1984249998Sdim}; 1985249998Sdim 1986249998Sdimtemplate <class _Fp, class _BoundArgs, class _TupleUj, 1987249998Sdim bool = _is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value> 1988227825Stheravenstruct __bind_return; 1989227825Stheraven 1990232950Stheraventemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 1991249998Sdimstruct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> 1992227825Stheraven{ 1993227825Stheraven typedef typename __invoke_of 1994227825Stheraven < 1995232950Stheraven _Fp&, 1996227825Stheraven typename __mu_return 1997227825Stheraven < 1998227825Stheraven _BoundArgs, 1999227825Stheraven _TupleUj 2000227825Stheraven >::type... 2001227825Stheraven >::type type; 2002227825Stheraven}; 2003227825Stheraven 2004232950Stheraventemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 2005249998Sdimstruct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> 2006227825Stheraven{ 2007227825Stheraven typedef typename __invoke_of 2008227825Stheraven < 2009232950Stheraven _Fp&, 2010227825Stheraven typename __mu_return 2011227825Stheraven < 2012227825Stheraven const _BoundArgs, 2013227825Stheraven _TupleUj 2014227825Stheraven >::type... 2015227825Stheraven >::type type; 2016227825Stheraven}; 2017227825Stheraven 2018232950Stheraventemplate <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args> 2019227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2020232950Stheraventypename __bind_return<_Fp, _BoundArgs, _Args>::type 2021232950Stheraven__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, 2022227825Stheraven _Args&& __args) 2023227825Stheraven{ 2024278724Sdim return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...); 2025227825Stheraven} 2026227825Stheraven 2027232950Stheraventemplate<class _Fp, class ..._BoundArgs> 2028227825Stheravenclass __bind 2029232950Stheraven : public __weak_result_type<typename decay<_Fp>::type> 2030227825Stheraven{ 2031249998Sdimprotected: 2032232950Stheraven typedef typename decay<_Fp>::type _Fd; 2033227825Stheraven typedef tuple<typename decay<_BoundArgs>::type...> _Td; 2034249998Sdimprivate: 2035227825Stheraven _Fd __f_; 2036227825Stheraven _Td __bound_args_; 2037227825Stheraven 2038227825Stheraven typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices; 2039227825Stheravenpublic: 2040227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2041227825Stheraven 2042227825Stheraven _LIBCPP_INLINE_VISIBILITY 2043227825Stheraven __bind(const __bind& __b) 2044227825Stheraven : __f_(__b.__f_), 2045227825Stheraven __bound_args_(__b.__bound_args_) {} 2046227825Stheraven 2047227825Stheraven _LIBCPP_INLINE_VISIBILITY 2048227825Stheraven __bind& operator=(const __bind& __b) 2049227825Stheraven { 2050227825Stheraven __f_ = __b.__f_; 2051227825Stheraven __bound_args_ = __b.__bound_args_; 2052227825Stheraven return *this; 2053227825Stheraven } 2054227825Stheraven 2055227825Stheraven _LIBCPP_INLINE_VISIBILITY 2056227825Stheraven __bind(__bind&& __b) 2057227825Stheraven : __f_(_VSTD::move(__b.__f_)), 2058227825Stheraven __bound_args_(_VSTD::move(__b.__bound_args_)) {} 2059227825Stheraven 2060227825Stheraven _LIBCPP_INLINE_VISIBILITY 2061227825Stheraven __bind& operator=(__bind&& __b) 2062227825Stheraven { 2063227825Stheraven __f_ = _VSTD::move(__b.__f_); 2064227825Stheraven __bound_args_ = _VSTD::move(__b.__bound_args_); 2065227825Stheraven return *this; 2066227825Stheraven } 2067227825Stheraven 2068227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2069227825Stheraven 2070241903Sdim template <class _Gp, class ..._BA, 2071241903Sdim class = typename enable_if 2072241903Sdim < 2073253159Stheraven is_constructible<_Fd, _Gp>::value && 2074253159Stheraven !is_same<typename remove_reference<_Gp>::type, 2075253159Stheraven __bind>::value 2076241903Sdim >::type> 2077227825Stheraven _LIBCPP_INLINE_VISIBILITY 2078232950Stheraven explicit __bind(_Gp&& __f, _BA&& ...__bound_args) 2079232950Stheraven : __f_(_VSTD::forward<_Gp>(__f)), 2080227825Stheraven __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {} 2081227825Stheraven 2082227825Stheraven template <class ..._Args> 2083227825Stheraven _LIBCPP_INLINE_VISIBILITY 2084227825Stheraven typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type 2085227825Stheraven operator()(_Args&& ...__args) 2086227825Stheraven { 2087227825Stheraven return __apply_functor(__f_, __bound_args_, __indices(), 2088227825Stheraven tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); 2089227825Stheraven } 2090227825Stheraven 2091227825Stheraven template <class ..._Args> 2092227825Stheraven _LIBCPP_INLINE_VISIBILITY 2093249998Sdim typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type 2094227825Stheraven operator()(_Args&& ...__args) const 2095227825Stheraven { 2096227825Stheraven return __apply_functor(__f_, __bound_args_, __indices(), 2097227825Stheraven tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); 2098227825Stheraven } 2099227825Stheraven}; 2100227825Stheraven 2101232950Stheraventemplate<class _Fp, class ..._BoundArgs> 2102232950Stheravenstruct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {}; 2103227825Stheraven 2104232950Stheraventemplate<class _Rp, class _Fp, class ..._BoundArgs> 2105227825Stheravenclass __bind_r 2106232950Stheraven : public __bind<_Fp, _BoundArgs...> 2107227825Stheraven{ 2108232950Stheraven typedef __bind<_Fp, _BoundArgs...> base; 2109249998Sdim typedef typename base::_Fd _Fd; 2110249998Sdim typedef typename base::_Td _Td; 2111227825Stheravenpublic: 2112232950Stheraven typedef _Rp result_type; 2113227825Stheraven 2114227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2115227825Stheraven 2116227825Stheraven _LIBCPP_INLINE_VISIBILITY 2117227825Stheraven __bind_r(const __bind_r& __b) 2118227825Stheraven : base(_VSTD::forward<const base&>(__b)) {} 2119227825Stheraven 2120227825Stheraven _LIBCPP_INLINE_VISIBILITY 2121227825Stheraven __bind_r& operator=(const __bind_r& __b) 2122227825Stheraven { 2123227825Stheraven base::operator=(_VSTD::forward<const base&>(__b)); 2124227825Stheraven return *this; 2125227825Stheraven } 2126227825Stheraven 2127227825Stheraven _LIBCPP_INLINE_VISIBILITY 2128227825Stheraven __bind_r(__bind_r&& __b) 2129227825Stheraven : base(_VSTD::forward<base>(__b)) {} 2130227825Stheraven 2131227825Stheraven _LIBCPP_INLINE_VISIBILITY 2132227825Stheraven __bind_r& operator=(__bind_r&& __b) 2133227825Stheraven { 2134227825Stheraven base::operator=(_VSTD::forward<base>(__b)); 2135227825Stheraven return *this; 2136227825Stheraven } 2137227825Stheraven 2138227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2139227825Stheraven 2140253159Stheraven template <class _Gp, class ..._BA, 2141253159Stheraven class = typename enable_if 2142253159Stheraven < 2143253159Stheraven is_constructible<_Fd, _Gp>::value && 2144253159Stheraven !is_same<typename remove_reference<_Gp>::type, 2145253159Stheraven __bind_r>::value 2146253159Stheraven >::type> 2147227825Stheraven _LIBCPP_INLINE_VISIBILITY 2148232950Stheraven explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args) 2149232950Stheraven : base(_VSTD::forward<_Gp>(__f), 2150227825Stheraven _VSTD::forward<_BA>(__bound_args)...) {} 2151227825Stheraven 2152227825Stheraven template <class ..._Args> 2153227825Stheraven _LIBCPP_INLINE_VISIBILITY 2154249998Sdim typename enable_if 2155249998Sdim < 2156249998Sdim is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type, 2157249998Sdim result_type>::value, 2158249998Sdim result_type 2159249998Sdim >::type 2160227825Stheraven operator()(_Args&& ...__args) 2161227825Stheraven { 2162227825Stheraven return base::operator()(_VSTD::forward<_Args>(__args)...); 2163227825Stheraven } 2164227825Stheraven 2165227825Stheraven template <class ..._Args> 2166227825Stheraven _LIBCPP_INLINE_VISIBILITY 2167249998Sdim typename enable_if 2168249998Sdim < 2169249998Sdim is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type, 2170249998Sdim result_type>::value, 2171249998Sdim result_type 2172249998Sdim >::type 2173227825Stheraven operator()(_Args&& ...__args) const 2174227825Stheraven { 2175227825Stheraven return base::operator()(_VSTD::forward<_Args>(__args)...); 2176227825Stheraven } 2177227825Stheraven}; 2178227825Stheraven 2179232950Stheraventemplate<class _Rp, class _Fp, class ..._BoundArgs> 2180232950Stheravenstruct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; 2181227825Stheraven 2182232950Stheraventemplate<class _Fp, class ..._BoundArgs> 2183227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2184232950Stheraven__bind<_Fp, _BoundArgs...> 2185232950Stheravenbind(_Fp&& __f, _BoundArgs&&... __bound_args) 2186227825Stheraven{ 2187232950Stheraven typedef __bind<_Fp, _BoundArgs...> type; 2188232950Stheraven return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); 2189227825Stheraven} 2190227825Stheraven 2191232950Stheraventemplate<class _Rp, class _Fp, class ..._BoundArgs> 2192227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2193232950Stheraven__bind_r<_Rp, _Fp, _BoundArgs...> 2194232950Stheravenbind(_Fp&& __f, _BoundArgs&&... __bound_args) 2195227825Stheraven{ 2196232950Stheraven typedef __bind_r<_Rp, _Fp, _BoundArgs...> type; 2197232950Stheraven return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); 2198227825Stheraven} 2199227825Stheraven 2200227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2201227825Stheraven 2202227825Stheraventemplate <> 2203262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<bool> 2204227825Stheraven : public unary_function<bool, size_t> 2205227825Stheraven{ 2206227825Stheraven _LIBCPP_INLINE_VISIBILITY 2207227825Stheraven size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2208227825Stheraven}; 2209227825Stheraven 2210227825Stheraventemplate <> 2211262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<char> 2212227825Stheraven : public unary_function<char, size_t> 2213227825Stheraven{ 2214227825Stheraven _LIBCPP_INLINE_VISIBILITY 2215227825Stheraven size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2216227825Stheraven}; 2217227825Stheraven 2218227825Stheraventemplate <> 2219262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<signed char> 2220227825Stheraven : public unary_function<signed char, size_t> 2221227825Stheraven{ 2222227825Stheraven _LIBCPP_INLINE_VISIBILITY 2223227825Stheraven size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2224227825Stheraven}; 2225227825Stheraven 2226227825Stheraventemplate <> 2227262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned char> 2228227825Stheraven : public unary_function<unsigned char, size_t> 2229227825Stheraven{ 2230227825Stheraven _LIBCPP_INLINE_VISIBILITY 2231227825Stheraven size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2232227825Stheraven}; 2233227825Stheraven 2234227825Stheraven#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 2235227825Stheraven 2236227825Stheraventemplate <> 2237262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<char16_t> 2238227825Stheraven : public unary_function<char16_t, size_t> 2239227825Stheraven{ 2240227825Stheraven _LIBCPP_INLINE_VISIBILITY 2241227825Stheraven size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2242227825Stheraven}; 2243227825Stheraven 2244227825Stheraventemplate <> 2245262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<char32_t> 2246227825Stheraven : public unary_function<char32_t, size_t> 2247227825Stheraven{ 2248227825Stheraven _LIBCPP_INLINE_VISIBILITY 2249227825Stheraven size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2250227825Stheraven}; 2251227825Stheraven 2252227825Stheraven#endif // _LIBCPP_HAS_NO_UNICODE_CHARS 2253227825Stheraven 2254227825Stheraventemplate <> 2255262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<wchar_t> 2256227825Stheraven : public unary_function<wchar_t, size_t> 2257227825Stheraven{ 2258227825Stheraven _LIBCPP_INLINE_VISIBILITY 2259227825Stheraven size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2260227825Stheraven}; 2261227825Stheraven 2262227825Stheraventemplate <> 2263262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<short> 2264227825Stheraven : public unary_function<short, size_t> 2265227825Stheraven{ 2266227825Stheraven _LIBCPP_INLINE_VISIBILITY 2267227825Stheraven size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2268227825Stheraven}; 2269227825Stheraven 2270227825Stheraventemplate <> 2271262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned short> 2272227825Stheraven : public unary_function<unsigned short, size_t> 2273227825Stheraven{ 2274227825Stheraven _LIBCPP_INLINE_VISIBILITY 2275227825Stheraven size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2276227825Stheraven}; 2277227825Stheraven 2278227825Stheraventemplate <> 2279262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<int> 2280227825Stheraven : public unary_function<int, size_t> 2281227825Stheraven{ 2282227825Stheraven _LIBCPP_INLINE_VISIBILITY 2283227825Stheraven size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2284227825Stheraven}; 2285227825Stheraven 2286227825Stheraventemplate <> 2287262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned int> 2288227825Stheraven : public unary_function<unsigned int, size_t> 2289227825Stheraven{ 2290227825Stheraven _LIBCPP_INLINE_VISIBILITY 2291227825Stheraven size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2292227825Stheraven}; 2293227825Stheraven 2294227825Stheraventemplate <> 2295262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<long> 2296227825Stheraven : public unary_function<long, size_t> 2297227825Stheraven{ 2298227825Stheraven _LIBCPP_INLINE_VISIBILITY 2299227825Stheraven size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2300227825Stheraven}; 2301227825Stheraven 2302227825Stheraventemplate <> 2303262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long> 2304227825Stheraven : public unary_function<unsigned long, size_t> 2305227825Stheraven{ 2306227825Stheraven _LIBCPP_INLINE_VISIBILITY 2307227825Stheraven size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2308227825Stheraven}; 2309227825Stheraven 2310227825Stheraventemplate <> 2311262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<long long> 2312232950Stheraven : public __scalar_hash<long long> 2313227825Stheraven{ 2314227825Stheraven}; 2315227825Stheraven 2316227825Stheraventemplate <> 2317262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long long> 2318232950Stheraven : public __scalar_hash<unsigned long long> 2319227825Stheraven{ 2320227825Stheraven}; 2321227825Stheraven 2322227825Stheraventemplate <> 2323262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<float> 2324232950Stheraven : public __scalar_hash<float> 2325227825Stheraven{ 2326227825Stheraven _LIBCPP_INLINE_VISIBILITY 2327227825Stheraven size_t operator()(float __v) const _NOEXCEPT 2328227825Stheraven { 2329232950Stheraven // -0.0 and 0.0 should return same hash 2330232950Stheraven if (__v == 0) 2331232950Stheraven return 0; 2332232950Stheraven return __scalar_hash<float>::operator()(__v); 2333227825Stheraven } 2334227825Stheraven}; 2335227825Stheraven 2336227825Stheraventemplate <> 2337262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<double> 2338232950Stheraven : public __scalar_hash<double> 2339227825Stheraven{ 2340227825Stheraven _LIBCPP_INLINE_VISIBILITY 2341227825Stheraven size_t operator()(double __v) const _NOEXCEPT 2342227825Stheraven { 2343232950Stheraven // -0.0 and 0.0 should return same hash 2344232950Stheraven if (__v == 0) 2345232950Stheraven return 0; 2346232950Stheraven return __scalar_hash<double>::operator()(__v); 2347227825Stheraven } 2348227825Stheraven}; 2349227825Stheraven 2350227825Stheraventemplate <> 2351262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<long double> 2352232950Stheraven : public __scalar_hash<long double> 2353227825Stheraven{ 2354227825Stheraven _LIBCPP_INLINE_VISIBILITY 2355227825Stheraven size_t operator()(long double __v) const _NOEXCEPT 2356227825Stheraven { 2357232950Stheraven // -0.0 and 0.0 should return same hash 2358227825Stheraven if (__v == 0) 2359227825Stheraven return 0; 2360232950Stheraven#if defined(__i386__) 2361232950Stheraven // Zero out padding bits 2362232950Stheraven union 2363232950Stheraven { 2364232950Stheraven long double __t; 2365232950Stheraven struct 2366232950Stheraven { 2367232950Stheraven size_t __a; 2368232950Stheraven size_t __b; 2369232950Stheraven size_t __c; 2370232950Stheraven size_t __d; 2371232950Stheraven }; 2372232950Stheraven } __u; 2373232950Stheraven __u.__a = 0; 2374232950Stheraven __u.__b = 0; 2375232950Stheraven __u.__c = 0; 2376232950Stheraven __u.__d = 0; 2377232950Stheraven __u.__t = __v; 2378232950Stheraven return __u.__a ^ __u.__b ^ __u.__c ^ __u.__d; 2379232950Stheraven#elif defined(__x86_64__) 2380232950Stheraven // Zero out padding bits 2381232950Stheraven union 2382232950Stheraven { 2383232950Stheraven long double __t; 2384232950Stheraven struct 2385232950Stheraven { 2386232950Stheraven size_t __a; 2387232950Stheraven size_t __b; 2388232950Stheraven }; 2389232950Stheraven } __u; 2390232950Stheraven __u.__a = 0; 2391232950Stheraven __u.__b = 0; 2392232950Stheraven __u.__t = __v; 2393232950Stheraven return __u.__a ^ __u.__b; 2394232950Stheraven#else 2395232950Stheraven return __scalar_hash<long double>::operator()(__v); 2396232950Stheraven#endif 2397227825Stheraven } 2398227825Stheraven}; 2399227825Stheraven 2400262801Sdim#if _LIBCPP_STD_VER > 11 2401262801Sdimtemplate <class _Tp> 2402262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash 2403262801Sdim : public unary_function<_Tp, size_t> 2404262801Sdim{ 2405262801Sdim static_assert(is_enum<_Tp>::value, "This hash only works for enumeration types"); 2406262801Sdim 2407262801Sdim _LIBCPP_INLINE_VISIBILITY 2408262801Sdim size_t operator()(_Tp __v) const _NOEXCEPT 2409262801Sdim { 2410262801Sdim typedef typename underlying_type<_Tp>::type type; 2411262801Sdim return hash<type>{}(static_cast<type>(__v)); 2412262801Sdim } 2413262801Sdim}; 2414262801Sdim#endif 2415262801Sdim 2416227825Stheraven// struct hash<T*> in <memory> 2417227825Stheraven 2418227825Stheraven_LIBCPP_END_NAMESPACE_STD 2419227825Stheraven 2420227825Stheraven#endif // _LIBCPP_FUNCTIONAL 2421