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{ 1370227825Stheraven return __invoke(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...); 1371227825Stheraven} 1372227825Stheraven 1373227825Stheraven#ifndef _LIBCPP_NO_RTTI 1374227825Stheraven 1375232950Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1376227825Stheravenconst void* 1377232950Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT 1378227825Stheraven{ 1379232950Stheraven if (__ti == typeid(_Fp)) 1380227825Stheraven return &__f_.first(); 1381227825Stheraven return (const void*)0; 1382227825Stheraven} 1383227825Stheraven 1384232950Stheraventemplate<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes> 1385227825Stheravenconst std::type_info& 1386232950Stheraven__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT 1387227825Stheraven{ 1388232950Stheraven return typeid(_Fp); 1389227825Stheraven} 1390227825Stheraven 1391227825Stheraven#endif // _LIBCPP_NO_RTTI 1392227825Stheraven 1393227825Stheraven} // __function 1394227825Stheraven 1395232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1396262801Sdimclass _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)> 1397232950Stheraven : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>, 1398232950Stheraven public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> 1399227825Stheraven{ 1400232950Stheraven typedef __function::__base<_Rp(_ArgTypes...)> __base; 1401250514Sdim typename aligned_storage<3*sizeof(void*)>::type __buf_; 1402227825Stheraven __base* __f_; 1403227825Stheraven 1404232950Stheraven template <class _Fp> 1405227825Stheraven _LIBCPP_INLINE_VISIBILITY 1406232950Stheraven static bool __not_null(const _Fp&) {return true;} 1407232950Stheraven template <class _R2, class ..._Ap> 1408227825Stheraven _LIBCPP_INLINE_VISIBILITY 1409232950Stheraven static bool __not_null(_R2 (*__p)(_Ap...)) {return __p;} 1410232950Stheraven template <class _R2, class _Cp, class ..._Ap> 1411227825Stheraven _LIBCPP_INLINE_VISIBILITY 1412232950Stheraven static bool __not_null(_R2 (_Cp::*__p)(_Ap...)) {return __p;} 1413232950Stheraven template <class _R2, class _Cp, class ..._Ap> 1414227825Stheraven _LIBCPP_INLINE_VISIBILITY 1415232950Stheraven static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const) {return __p;} 1416232950Stheraven template <class _R2, class _Cp, class ..._Ap> 1417227825Stheraven _LIBCPP_INLINE_VISIBILITY 1418232950Stheraven static bool __not_null(_R2 (_Cp::*__p)(_Ap...) volatile) {return __p;} 1419232950Stheraven template <class _R2, class _Cp, class ..._Ap> 1420227825Stheraven _LIBCPP_INLINE_VISIBILITY 1421232950Stheraven static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const volatile) {return __p;} 1422232950Stheraven template <class _R2, class ..._Ap> 1423227825Stheraven _LIBCPP_INLINE_VISIBILITY 1424232950Stheraven static bool __not_null(const function<_Rp(_Ap...)>& __p) {return __p;} 1425227825Stheraven 1426243376Sdim template <class _Fp, bool = !is_same<_Fp, function>::value && 1427243376Sdim __invokable<_Fp&, _ArgTypes...>::value> 1428227825Stheraven struct __callable; 1429232950Stheraven template <class _Fp> 1430232950Stheraven struct __callable<_Fp, true> 1431227825Stheraven { 1432227825Stheraven static const bool value = 1433232950Stheraven is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type, 1434232950Stheraven _Rp>::value; 1435227825Stheraven }; 1436232950Stheraven template <class _Fp> 1437232950Stheraven struct __callable<_Fp, false> 1438227825Stheraven { 1439227825Stheraven static const bool value = false; 1440227825Stheraven }; 1441227825Stheravenpublic: 1442232950Stheraven typedef _Rp result_type; 1443227825Stheraven 1444227825Stheraven // construct/copy/destroy: 1445227825Stheraven _LIBCPP_INLINE_VISIBILITY 1446227825Stheraven function() _NOEXCEPT : __f_(0) {} 1447227825Stheraven _LIBCPP_INLINE_VISIBILITY 1448227825Stheraven function(nullptr_t) _NOEXCEPT : __f_(0) {} 1449227825Stheraven function(const function&); 1450227825Stheraven function(function&&) _NOEXCEPT; 1451232950Stheraven template<class _Fp> 1452253222Sdim function(_Fp, typename enable_if 1453253222Sdim < 1454253222Sdim __callable<_Fp>::value && 1455253222Sdim !is_same<_Fp, function>::value 1456253222Sdim >::type* = 0); 1457227825Stheraven 1458227825Stheraven template<class _Alloc> 1459227825Stheraven _LIBCPP_INLINE_VISIBILITY 1460227825Stheraven function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {} 1461227825Stheraven template<class _Alloc> 1462227825Stheraven _LIBCPP_INLINE_VISIBILITY 1463227825Stheraven function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {} 1464227825Stheraven template<class _Alloc> 1465227825Stheraven function(allocator_arg_t, const _Alloc&, const function&); 1466227825Stheraven template<class _Alloc> 1467227825Stheraven function(allocator_arg_t, const _Alloc&, function&&); 1468232950Stheraven template<class _Fp, class _Alloc> 1469232950Stheraven function(allocator_arg_t, const _Alloc& __a, _Fp __f, 1470232950Stheraven typename enable_if<__callable<_Fp>::value>::type* = 0); 1471227825Stheraven 1472227825Stheraven function& operator=(const function&); 1473227825Stheraven function& operator=(function&&) _NOEXCEPT; 1474227825Stheraven function& operator=(nullptr_t) _NOEXCEPT; 1475232950Stheraven template<class _Fp> 1476227825Stheraven typename enable_if 1477227825Stheraven < 1478253222Sdim __callable<typename decay<_Fp>::type>::value && 1479253222Sdim !is_same<typename remove_reference<_Fp>::type, function>::value, 1480227825Stheraven function& 1481227825Stheraven >::type 1482232950Stheraven operator=(_Fp&&); 1483227825Stheraven 1484227825Stheraven ~function(); 1485227825Stheraven 1486227825Stheraven // function modifiers: 1487227825Stheraven void swap(function&) _NOEXCEPT; 1488232950Stheraven template<class _Fp, class _Alloc> 1489227825Stheraven _LIBCPP_INLINE_VISIBILITY 1490232950Stheraven void assign(_Fp&& __f, const _Alloc& __a) 1491232950Stheraven {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);} 1492227825Stheraven 1493227825Stheraven // function capacity: 1494227825Stheraven _LIBCPP_INLINE_VISIBILITY 1495232950Stheraven _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;} 1496227825Stheraven 1497227825Stheraven // deleted overloads close possible hole in the type system 1498227825Stheraven template<class _R2, class... _ArgTypes2> 1499227825Stheraven bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete; 1500227825Stheraven template<class _R2, class... _ArgTypes2> 1501227825Stheraven bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete; 1502227825Stheravenpublic: 1503227825Stheraven // function invocation: 1504232950Stheraven _Rp operator()(_ArgTypes...) const; 1505227825Stheraven 1506227825Stheraven#ifndef _LIBCPP_NO_RTTI 1507227825Stheraven // function target access: 1508227825Stheraven const std::type_info& target_type() const _NOEXCEPT; 1509232950Stheraven template <typename _Tp> _Tp* target() _NOEXCEPT; 1510232950Stheraven template <typename _Tp> const _Tp* target() const _NOEXCEPT; 1511227825Stheraven#endif // _LIBCPP_NO_RTTI 1512227825Stheraven}; 1513227825Stheraven 1514232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1515232950Stheravenfunction<_Rp(_ArgTypes...)>::function(const function& __f) 1516227825Stheraven{ 1517227825Stheraven if (__f.__f_ == 0) 1518227825Stheraven __f_ = 0; 1519227825Stheraven else if (__f.__f_ == (const __base*)&__f.__buf_) 1520227825Stheraven { 1521227825Stheraven __f_ = (__base*)&__buf_; 1522227825Stheraven __f.__f_->__clone(__f_); 1523227825Stheraven } 1524227825Stheraven else 1525227825Stheraven __f_ = __f.__f_->__clone(); 1526227825Stheraven} 1527227825Stheraven 1528232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1529227825Stheraventemplate <class _Alloc> 1530232950Stheravenfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, 1531227825Stheraven const function& __f) 1532227825Stheraven{ 1533227825Stheraven if (__f.__f_ == 0) 1534227825Stheraven __f_ = 0; 1535227825Stheraven else if (__f.__f_ == (const __base*)&__f.__buf_) 1536227825Stheraven { 1537227825Stheraven __f_ = (__base*)&__buf_; 1538227825Stheraven __f.__f_->__clone(__f_); 1539227825Stheraven } 1540227825Stheraven else 1541227825Stheraven __f_ = __f.__f_->__clone(); 1542227825Stheraven} 1543227825Stheraven 1544232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1545232950Stheravenfunction<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT 1546227825Stheraven{ 1547227825Stheraven if (__f.__f_ == 0) 1548227825Stheraven __f_ = 0; 1549227825Stheraven else if (__f.__f_ == (__base*)&__f.__buf_) 1550227825Stheraven { 1551227825Stheraven __f_ = (__base*)&__buf_; 1552227825Stheraven __f.__f_->__clone(__f_); 1553227825Stheraven } 1554227825Stheraven else 1555227825Stheraven { 1556227825Stheraven __f_ = __f.__f_; 1557227825Stheraven __f.__f_ = 0; 1558227825Stheraven } 1559227825Stheraven} 1560227825Stheraven 1561232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1562227825Stheraventemplate <class _Alloc> 1563232950Stheravenfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, 1564227825Stheraven function&& __f) 1565227825Stheraven{ 1566227825Stheraven if (__f.__f_ == 0) 1567227825Stheraven __f_ = 0; 1568227825Stheraven else if (__f.__f_ == (__base*)&__f.__buf_) 1569227825Stheraven { 1570227825Stheraven __f_ = (__base*)&__buf_; 1571227825Stheraven __f.__f_->__clone(__f_); 1572227825Stheraven } 1573227825Stheraven else 1574227825Stheraven { 1575227825Stheraven __f_ = __f.__f_; 1576227825Stheraven __f.__f_ = 0; 1577227825Stheraven } 1578227825Stheraven} 1579227825Stheraven 1580232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1581232950Stheraventemplate <class _Fp> 1582232950Stheravenfunction<_Rp(_ArgTypes...)>::function(_Fp __f, 1583253222Sdim typename enable_if 1584253222Sdim < 1585253222Sdim __callable<_Fp>::value && 1586253222Sdim !is_same<_Fp, function>::value 1587253222Sdim >::type*) 1588227825Stheraven : __f_(0) 1589227825Stheraven{ 1590227825Stheraven if (__not_null(__f)) 1591227825Stheraven { 1592232950Stheraven typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF; 1593232950Stheraven if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) 1594227825Stheraven { 1595227825Stheraven __f_ = (__base*)&__buf_; 1596227825Stheraven ::new (__f_) _FF(_VSTD::move(__f)); 1597227825Stheraven } 1598227825Stheraven else 1599227825Stheraven { 1600232950Stheraven typedef allocator<_FF> _Ap; 1601232950Stheraven _Ap __a; 1602232950Stheraven typedef __allocator_destructor<_Ap> _Dp; 1603232950Stheraven unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1604232950Stheraven ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a)); 1605227825Stheraven __f_ = __hold.release(); 1606227825Stheraven } 1607227825Stheraven } 1608227825Stheraven} 1609227825Stheraven 1610232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1611232950Stheraventemplate <class _Fp, class _Alloc> 1612232950Stheravenfunction<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, 1613232950Stheraven typename enable_if<__callable<_Fp>::value>::type*) 1614227825Stheraven : __f_(0) 1615227825Stheraven{ 1616227825Stheraven typedef allocator_traits<_Alloc> __alloc_traits; 1617227825Stheraven if (__not_null(__f)) 1618227825Stheraven { 1619232950Stheraven typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF; 1620232950Stheraven if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) 1621227825Stheraven { 1622227825Stheraven __f_ = (__base*)&__buf_; 1623227825Stheraven ::new (__f_) _FF(_VSTD::move(__f)); 1624227825Stheraven } 1625227825Stheraven else 1626227825Stheraven { 1627227825Stheraven typedef typename __alloc_traits::template 1628227825Stheraven#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES 1629227825Stheraven rebind_alloc<_FF> 1630227825Stheraven#else 1631227825Stheraven rebind_alloc<_FF>::other 1632227825Stheraven#endif 1633232950Stheraven _Ap; 1634232950Stheraven _Ap __a(__a0); 1635232950Stheraven typedef __allocator_destructor<_Ap> _Dp; 1636232950Stheraven unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); 1637227825Stheraven ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a)); 1638227825Stheraven __f_ = __hold.release(); 1639227825Stheraven } 1640227825Stheraven } 1641227825Stheraven} 1642227825Stheraven 1643232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1644232950Stheravenfunction<_Rp(_ArgTypes...)>& 1645232950Stheravenfunction<_Rp(_ArgTypes...)>::operator=(const function& __f) 1646227825Stheraven{ 1647227825Stheraven function(__f).swap(*this); 1648227825Stheraven return *this; 1649227825Stheraven} 1650227825Stheraven 1651232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1652232950Stheravenfunction<_Rp(_ArgTypes...)>& 1653232950Stheravenfunction<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT 1654227825Stheraven{ 1655227825Stheraven if (__f_ == (__base*)&__buf_) 1656227825Stheraven __f_->destroy(); 1657227825Stheraven else if (__f_) 1658227825Stheraven __f_->destroy_deallocate(); 1659227825Stheraven __f_ = 0; 1660227825Stheraven if (__f.__f_ == 0) 1661227825Stheraven __f_ = 0; 1662227825Stheraven else if (__f.__f_ == (__base*)&__f.__buf_) 1663227825Stheraven { 1664227825Stheraven __f_ = (__base*)&__buf_; 1665227825Stheraven __f.__f_->__clone(__f_); 1666227825Stheraven } 1667227825Stheraven else 1668227825Stheraven { 1669227825Stheraven __f_ = __f.__f_; 1670227825Stheraven __f.__f_ = 0; 1671227825Stheraven } 1672243376Sdim return *this; 1673227825Stheraven} 1674227825Stheraven 1675232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1676232950Stheravenfunction<_Rp(_ArgTypes...)>& 1677232950Stheravenfunction<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT 1678227825Stheraven{ 1679227825Stheraven if (__f_ == (__base*)&__buf_) 1680227825Stheraven __f_->destroy(); 1681227825Stheraven else if (__f_) 1682227825Stheraven __f_->destroy_deallocate(); 1683227825Stheraven __f_ = 0; 1684243376Sdim return *this; 1685227825Stheraven} 1686227825Stheraven 1687232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1688232950Stheraventemplate <class _Fp> 1689227825Stheraventypename enable_if 1690227825Stheraven< 1691253222Sdim function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value && 1692253222Sdim !is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value, 1693232950Stheraven function<_Rp(_ArgTypes...)>& 1694227825Stheraven>::type 1695232950Stheravenfunction<_Rp(_ArgTypes...)>::operator=(_Fp&& __f) 1696227825Stheraven{ 1697232950Stheraven function(_VSTD::forward<_Fp>(__f)).swap(*this); 1698227825Stheraven return *this; 1699227825Stheraven} 1700227825Stheraven 1701232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1702232950Stheravenfunction<_Rp(_ArgTypes...)>::~function() 1703227825Stheraven{ 1704227825Stheraven if (__f_ == (__base*)&__buf_) 1705227825Stheraven __f_->destroy(); 1706227825Stheraven else if (__f_) 1707227825Stheraven __f_->destroy_deallocate(); 1708227825Stheraven} 1709227825Stheraven 1710232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1711227825Stheravenvoid 1712232950Stheravenfunction<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT 1713227825Stheraven{ 1714227825Stheraven if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) 1715227825Stheraven { 1716227825Stheraven typename aligned_storage<sizeof(__buf_)>::type __tempbuf; 1717227825Stheraven __base* __t = (__base*)&__tempbuf; 1718227825Stheraven __f_->__clone(__t); 1719227825Stheraven __f_->destroy(); 1720227825Stheraven __f_ = 0; 1721227825Stheraven __f.__f_->__clone((__base*)&__buf_); 1722227825Stheraven __f.__f_->destroy(); 1723227825Stheraven __f.__f_ = 0; 1724227825Stheraven __f_ = (__base*)&__buf_; 1725227825Stheraven __t->__clone((__base*)&__f.__buf_); 1726227825Stheraven __t->destroy(); 1727227825Stheraven __f.__f_ = (__base*)&__f.__buf_; 1728227825Stheraven } 1729227825Stheraven else if (__f_ == (__base*)&__buf_) 1730227825Stheraven { 1731227825Stheraven __f_->__clone((__base*)&__f.__buf_); 1732227825Stheraven __f_->destroy(); 1733227825Stheraven __f_ = __f.__f_; 1734227825Stheraven __f.__f_ = (__base*)&__f.__buf_; 1735227825Stheraven } 1736227825Stheraven else if (__f.__f_ == (__base*)&__f.__buf_) 1737227825Stheraven { 1738227825Stheraven __f.__f_->__clone((__base*)&__buf_); 1739227825Stheraven __f.__f_->destroy(); 1740227825Stheraven __f.__f_ = __f_; 1741227825Stheraven __f_ = (__base*)&__buf_; 1742227825Stheraven } 1743227825Stheraven else 1744227825Stheraven _VSTD::swap(__f_, __f.__f_); 1745227825Stheraven} 1746227825Stheraven 1747232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1748232950Stheraven_Rp 1749232950Stheravenfunction<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const 1750227825Stheraven{ 1751227825Stheraven#ifndef _LIBCPP_NO_EXCEPTIONS 1752227825Stheraven if (__f_ == 0) 1753227825Stheraven throw bad_function_call(); 1754227825Stheraven#endif // _LIBCPP_NO_EXCEPTIONS 1755227825Stheraven return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...); 1756227825Stheraven} 1757227825Stheraven 1758227825Stheraven#ifndef _LIBCPP_NO_RTTI 1759227825Stheraven 1760232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1761227825Stheravenconst std::type_info& 1762232950Stheravenfunction<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT 1763227825Stheraven{ 1764227825Stheraven if (__f_ == 0) 1765227825Stheraven return typeid(void); 1766227825Stheraven return __f_->target_type(); 1767227825Stheraven} 1768227825Stheraven 1769232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1770232950Stheraventemplate <typename _Tp> 1771232950Stheraven_Tp* 1772232950Stheravenfunction<_Rp(_ArgTypes...)>::target() _NOEXCEPT 1773227825Stheraven{ 1774227825Stheraven if (__f_ == 0) 1775232950Stheraven return (_Tp*)0; 1776232950Stheraven return (_Tp*)__f_->target(typeid(_Tp)); 1777227825Stheraven} 1778227825Stheraven 1779232950Stheraventemplate<class _Rp, class ..._ArgTypes> 1780232950Stheraventemplate <typename _Tp> 1781232950Stheravenconst _Tp* 1782232950Stheravenfunction<_Rp(_ArgTypes...)>::target() const _NOEXCEPT 1783227825Stheraven{ 1784227825Stheraven if (__f_ == 0) 1785232950Stheraven return (const _Tp*)0; 1786232950Stheraven return (const _Tp*)__f_->target(typeid(_Tp)); 1787227825Stheraven} 1788227825Stheraven 1789227825Stheraven#endif // _LIBCPP_NO_RTTI 1790227825Stheraven 1791232950Stheraventemplate <class _Rp, class... _ArgTypes> 1792227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1793227825Stheravenbool 1794232950Stheravenoperator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;} 1795227825Stheraven 1796232950Stheraventemplate <class _Rp, class... _ArgTypes> 1797227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1798227825Stheravenbool 1799232950Stheravenoperator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;} 1800227825Stheraven 1801232950Stheraventemplate <class _Rp, class... _ArgTypes> 1802227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1803227825Stheravenbool 1804232950Stheravenoperator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;} 1805227825Stheraven 1806232950Stheraventemplate <class _Rp, class... _ArgTypes> 1807227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1808227825Stheravenbool 1809232950Stheravenoperator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;} 1810227825Stheraven 1811232950Stheraventemplate <class _Rp, class... _ArgTypes> 1812227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1813227825Stheravenvoid 1814232950Stheravenswap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT 1815227825Stheraven{return __x.swap(__y);} 1816227825Stheraven 1817227825Stheraventemplate<class _Tp> struct __is_bind_expression : public false_type {}; 1818262801Sdimtemplate<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression 1819227825Stheraven : public __is_bind_expression<typename remove_cv<_Tp>::type> {}; 1820227825Stheraven 1821227825Stheraventemplate<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {}; 1822262801Sdimtemplate<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_placeholder 1823227825Stheraven : public __is_placeholder<typename remove_cv<_Tp>::type> {}; 1824227825Stheraven 1825227825Stheravennamespace placeholders 1826227825Stheraven{ 1827227825Stheraven 1828232950Stheraventemplate <int _Np> struct __ph {}; 1829227825Stheraven 1830262801Sdim_LIBCPP_FUNC_VIS extern __ph<1> _1; 1831262801Sdim_LIBCPP_FUNC_VIS extern __ph<2> _2; 1832262801Sdim_LIBCPP_FUNC_VIS extern __ph<3> _3; 1833262801Sdim_LIBCPP_FUNC_VIS extern __ph<4> _4; 1834262801Sdim_LIBCPP_FUNC_VIS extern __ph<5> _5; 1835262801Sdim_LIBCPP_FUNC_VIS extern __ph<6> _6; 1836262801Sdim_LIBCPP_FUNC_VIS extern __ph<7> _7; 1837262801Sdim_LIBCPP_FUNC_VIS extern __ph<8> _8; 1838262801Sdim_LIBCPP_FUNC_VIS extern __ph<9> _9; 1839262801Sdim_LIBCPP_FUNC_VIS extern __ph<10> _10; 1840227825Stheraven 1841227825Stheraven} // placeholders 1842227825Stheraven 1843232950Stheraventemplate<int _Np> 1844232950Stheravenstruct __is_placeholder<placeholders::__ph<_Np> > 1845232950Stheraven : public integral_constant<int, _Np> {}; 1846227825Stheraven 1847227825Stheraventemplate <class _Tp, class _Uj> 1848227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1849227825Stheraven_Tp& 1850227825Stheraven__mu(reference_wrapper<_Tp> __t, _Uj&) 1851227825Stheraven{ 1852227825Stheraven return __t.get(); 1853227825Stheraven} 1854227825Stheraven 1855227825Stheraventemplate <class _Ti, class ..._Uj, size_t ..._Indx> 1856227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1857227825Stheraventypename __invoke_of<_Ti&, _Uj...>::type 1858227825Stheraven__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) 1859227825Stheraven{ 1860227825Stheraven return __ti(_VSTD::forward<_Uj>(get<_Indx>(__uj))...); 1861227825Stheraven} 1862227825Stheraven 1863227825Stheraventemplate <class _Ti, class ..._Uj> 1864227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1865227825Stheraventypename enable_if 1866227825Stheraven< 1867227825Stheraven is_bind_expression<_Ti>::value, 1868227825Stheraven typename __invoke_of<_Ti&, _Uj...>::type 1869227825Stheraven>::type 1870227825Stheraven__mu(_Ti& __ti, tuple<_Uj...>& __uj) 1871227825Stheraven{ 1872227825Stheraven typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices; 1873227825Stheraven return __mu_expand(__ti, __uj, __indices()); 1874227825Stheraven} 1875227825Stheraven 1876227825Stheraventemplate <bool IsPh, class _Ti, class _Uj> 1877227825Stheravenstruct __mu_return2 {}; 1878227825Stheraven 1879227825Stheraventemplate <class _Ti, class _Uj> 1880227825Stheravenstruct __mu_return2<true, _Ti, _Uj> 1881227825Stheraven{ 1882227825Stheraven typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type; 1883227825Stheraven}; 1884227825Stheraven 1885227825Stheraventemplate <class _Ti, class _Uj> 1886227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1887227825Stheraventypename enable_if 1888227825Stheraven< 1889227825Stheraven 0 < is_placeholder<_Ti>::value, 1890227825Stheraven typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type 1891227825Stheraven>::type 1892227825Stheraven__mu(_Ti&, _Uj& __uj) 1893227825Stheraven{ 1894227825Stheraven const size_t _Indx = is_placeholder<_Ti>::value - 1; 1895227825Stheraven return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(get<_Indx>(__uj)); 1896227825Stheraven} 1897227825Stheraven 1898227825Stheraventemplate <class _Ti, class _Uj> 1899227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 1900227825Stheraventypename enable_if 1901227825Stheraven< 1902227825Stheraven !is_bind_expression<_Ti>::value && 1903227825Stheraven is_placeholder<_Ti>::value == 0 && 1904227825Stheraven !__is_reference_wrapper<_Ti>::value, 1905227825Stheraven _Ti& 1906227825Stheraven>::type 1907232950Stheraven__mu(_Ti& __ti, _Uj&) 1908227825Stheraven{ 1909227825Stheraven return __ti; 1910227825Stheraven} 1911227825Stheraven 1912227825Stheraventemplate <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh, 1913227825Stheraven class _TupleUj> 1914227825Stheravenstruct ____mu_return; 1915227825Stheraven 1916253222Sdimtemplate <bool _Invokable, class _Ti, class ..._Uj> 1917253222Sdimstruct ____mu_return_invokable // false 1918253222Sdim{ 1919253222Sdim typedef __nat type; 1920253222Sdim}; 1921253222Sdim 1922227825Stheraventemplate <class _Ti, class ..._Uj> 1923253222Sdimstruct ____mu_return_invokable<true, _Ti, _Uj...> 1924227825Stheraven{ 1925227825Stheraven typedef typename __invoke_of<_Ti&, _Uj...>::type type; 1926227825Stheraven}; 1927227825Stheraven 1928253222Sdimtemplate <class _Ti, class ..._Uj> 1929253222Sdimstruct ____mu_return<_Ti, false, true, false, tuple<_Uj...> > 1930253222Sdim : public ____mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...> 1931253222Sdim{ 1932253222Sdim}; 1933253222Sdim 1934227825Stheraventemplate <class _Ti, class _TupleUj> 1935227825Stheravenstruct ____mu_return<_Ti, false, false, true, _TupleUj> 1936227825Stheraven{ 1937227825Stheraven typedef typename tuple_element<is_placeholder<_Ti>::value - 1, 1938227825Stheraven _TupleUj>::type&& type; 1939227825Stheraven}; 1940227825Stheraven 1941227825Stheraventemplate <class _Ti, class _TupleUj> 1942227825Stheravenstruct ____mu_return<_Ti, true, false, false, _TupleUj> 1943227825Stheraven{ 1944227825Stheraven typedef typename _Ti::type& type; 1945227825Stheraven}; 1946227825Stheraven 1947227825Stheraventemplate <class _Ti, class _TupleUj> 1948227825Stheravenstruct ____mu_return<_Ti, false, false, false, _TupleUj> 1949227825Stheraven{ 1950227825Stheraven typedef _Ti& type; 1951227825Stheraven}; 1952227825Stheraven 1953227825Stheraventemplate <class _Ti, class _TupleUj> 1954227825Stheravenstruct __mu_return 1955227825Stheraven : public ____mu_return<_Ti, 1956227825Stheraven __is_reference_wrapper<_Ti>::value, 1957227825Stheraven is_bind_expression<_Ti>::value, 1958250514Sdim 0 < is_placeholder<_Ti>::value && 1959250514Sdim is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value, 1960227825Stheraven _TupleUj> 1961227825Stheraven{ 1962227825Stheraven}; 1963227825Stheraven 1964232950Stheraventemplate <class _Fp, class _BoundArgs, class _TupleUj> 1965250514Sdimstruct _is_valid_bind_return 1966250514Sdim{ 1967250514Sdim static const bool value = false; 1968250514Sdim}; 1969250514Sdim 1970250514Sdimtemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 1971250514Sdimstruct _is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> 1972250514Sdim{ 1973250514Sdim static const bool value = __invokable<_Fp, 1974250514Sdim typename __mu_return<_BoundArgs, _TupleUj>::type...>::value; 1975250514Sdim}; 1976250514Sdim 1977250514Sdimtemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 1978250514Sdimstruct _is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> 1979250514Sdim{ 1980250514Sdim static const bool value = __invokable<_Fp, 1981250514Sdim typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value; 1982250514Sdim}; 1983250514Sdim 1984250514Sdimtemplate <class _Fp, class _BoundArgs, class _TupleUj, 1985250514Sdim bool = _is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value> 1986227825Stheravenstruct __bind_return; 1987227825Stheraven 1988232950Stheraventemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 1989250514Sdimstruct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> 1990227825Stheraven{ 1991227825Stheraven typedef typename __invoke_of 1992227825Stheraven < 1993232950Stheraven _Fp&, 1994227825Stheraven typename __mu_return 1995227825Stheraven < 1996227825Stheraven _BoundArgs, 1997227825Stheraven _TupleUj 1998227825Stheraven >::type... 1999227825Stheraven >::type type; 2000227825Stheraven}; 2001227825Stheraven 2002232950Stheraventemplate <class _Fp, class ..._BoundArgs, class _TupleUj> 2003250514Sdimstruct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> 2004227825Stheraven{ 2005227825Stheraven typedef typename __invoke_of 2006227825Stheraven < 2007232950Stheraven _Fp&, 2008227825Stheraven typename __mu_return 2009227825Stheraven < 2010227825Stheraven const _BoundArgs, 2011227825Stheraven _TupleUj 2012227825Stheraven >::type... 2013227825Stheraven >::type type; 2014227825Stheraven}; 2015227825Stheraven 2016232950Stheraventemplate <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args> 2017227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2018232950Stheraventypename __bind_return<_Fp, _BoundArgs, _Args>::type 2019232950Stheraven__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, 2020227825Stheraven _Args&& __args) 2021227825Stheraven{ 2022227825Stheraven return __invoke(__f, __mu(get<_Indx>(__bound_args), __args)...); 2023227825Stheraven} 2024227825Stheraven 2025232950Stheraventemplate<class _Fp, class ..._BoundArgs> 2026227825Stheravenclass __bind 2027232950Stheraven : public __weak_result_type<typename decay<_Fp>::type> 2028227825Stheraven{ 2029250514Sdimprotected: 2030232950Stheraven typedef typename decay<_Fp>::type _Fd; 2031227825Stheraven typedef tuple<typename decay<_BoundArgs>::type...> _Td; 2032250514Sdimprivate: 2033227825Stheraven _Fd __f_; 2034227825Stheraven _Td __bound_args_; 2035227825Stheraven 2036227825Stheraven typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices; 2037227825Stheravenpublic: 2038227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2039227825Stheraven 2040227825Stheraven _LIBCPP_INLINE_VISIBILITY 2041227825Stheraven __bind(const __bind& __b) 2042227825Stheraven : __f_(__b.__f_), 2043227825Stheraven __bound_args_(__b.__bound_args_) {} 2044227825Stheraven 2045227825Stheraven _LIBCPP_INLINE_VISIBILITY 2046227825Stheraven __bind& operator=(const __bind& __b) 2047227825Stheraven { 2048227825Stheraven __f_ = __b.__f_; 2049227825Stheraven __bound_args_ = __b.__bound_args_; 2050227825Stheraven return *this; 2051227825Stheraven } 2052227825Stheraven 2053227825Stheraven _LIBCPP_INLINE_VISIBILITY 2054227825Stheraven __bind(__bind&& __b) 2055227825Stheraven : __f_(_VSTD::move(__b.__f_)), 2056227825Stheraven __bound_args_(_VSTD::move(__b.__bound_args_)) {} 2057227825Stheraven 2058227825Stheraven _LIBCPP_INLINE_VISIBILITY 2059227825Stheraven __bind& operator=(__bind&& __b) 2060227825Stheraven { 2061227825Stheraven __f_ = _VSTD::move(__b.__f_); 2062227825Stheraven __bound_args_ = _VSTD::move(__b.__bound_args_); 2063227825Stheraven return *this; 2064227825Stheraven } 2065227825Stheraven 2066227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2067227825Stheraven 2068243376Sdim template <class _Gp, class ..._BA, 2069243376Sdim class = typename enable_if 2070243376Sdim < 2071253222Sdim is_constructible<_Fd, _Gp>::value && 2072253222Sdim !is_same<typename remove_reference<_Gp>::type, 2073253222Sdim __bind>::value 2074243376Sdim >::type> 2075227825Stheraven _LIBCPP_INLINE_VISIBILITY 2076232950Stheraven explicit __bind(_Gp&& __f, _BA&& ...__bound_args) 2077232950Stheraven : __f_(_VSTD::forward<_Gp>(__f)), 2078227825Stheraven __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {} 2079227825Stheraven 2080227825Stheraven template <class ..._Args> 2081227825Stheraven _LIBCPP_INLINE_VISIBILITY 2082227825Stheraven typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type 2083227825Stheraven operator()(_Args&& ...__args) 2084227825Stheraven { 2085227825Stheraven return __apply_functor(__f_, __bound_args_, __indices(), 2086227825Stheraven tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); 2087227825Stheraven } 2088227825Stheraven 2089227825Stheraven template <class ..._Args> 2090227825Stheraven _LIBCPP_INLINE_VISIBILITY 2091250514Sdim typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type 2092227825Stheraven operator()(_Args&& ...__args) const 2093227825Stheraven { 2094227825Stheraven return __apply_functor(__f_, __bound_args_, __indices(), 2095227825Stheraven tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); 2096227825Stheraven } 2097227825Stheraven}; 2098227825Stheraven 2099232950Stheraventemplate<class _Fp, class ..._BoundArgs> 2100232950Stheravenstruct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {}; 2101227825Stheraven 2102232950Stheraventemplate<class _Rp, class _Fp, class ..._BoundArgs> 2103227825Stheravenclass __bind_r 2104232950Stheraven : public __bind<_Fp, _BoundArgs...> 2105227825Stheraven{ 2106232950Stheraven typedef __bind<_Fp, _BoundArgs...> base; 2107250514Sdim typedef typename base::_Fd _Fd; 2108250514Sdim typedef typename base::_Td _Td; 2109227825Stheravenpublic: 2110232950Stheraven typedef _Rp result_type; 2111227825Stheraven 2112227825Stheraven#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2113227825Stheraven 2114227825Stheraven _LIBCPP_INLINE_VISIBILITY 2115227825Stheraven __bind_r(const __bind_r& __b) 2116227825Stheraven : base(_VSTD::forward<const base&>(__b)) {} 2117227825Stheraven 2118227825Stheraven _LIBCPP_INLINE_VISIBILITY 2119227825Stheraven __bind_r& operator=(const __bind_r& __b) 2120227825Stheraven { 2121227825Stheraven base::operator=(_VSTD::forward<const base&>(__b)); 2122227825Stheraven return *this; 2123227825Stheraven } 2124227825Stheraven 2125227825Stheraven _LIBCPP_INLINE_VISIBILITY 2126227825Stheraven __bind_r(__bind_r&& __b) 2127227825Stheraven : base(_VSTD::forward<base>(__b)) {} 2128227825Stheraven 2129227825Stheraven _LIBCPP_INLINE_VISIBILITY 2130227825Stheraven __bind_r& operator=(__bind_r&& __b) 2131227825Stheraven { 2132227825Stheraven base::operator=(_VSTD::forward<base>(__b)); 2133227825Stheraven return *this; 2134227825Stheraven } 2135227825Stheraven 2136227825Stheraven#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 2137227825Stheraven 2138253222Sdim template <class _Gp, class ..._BA, 2139253222Sdim class = typename enable_if 2140253222Sdim < 2141253222Sdim is_constructible<_Fd, _Gp>::value && 2142253222Sdim !is_same<typename remove_reference<_Gp>::type, 2143253222Sdim __bind_r>::value 2144253222Sdim >::type> 2145227825Stheraven _LIBCPP_INLINE_VISIBILITY 2146232950Stheraven explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args) 2147232950Stheraven : base(_VSTD::forward<_Gp>(__f), 2148227825Stheraven _VSTD::forward<_BA>(__bound_args)...) {} 2149227825Stheraven 2150227825Stheraven template <class ..._Args> 2151227825Stheraven _LIBCPP_INLINE_VISIBILITY 2152250514Sdim typename enable_if 2153250514Sdim < 2154250514Sdim is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type, 2155250514Sdim result_type>::value, 2156250514Sdim result_type 2157250514Sdim >::type 2158227825Stheraven operator()(_Args&& ...__args) 2159227825Stheraven { 2160227825Stheraven return base::operator()(_VSTD::forward<_Args>(__args)...); 2161227825Stheraven } 2162227825Stheraven 2163227825Stheraven template <class ..._Args> 2164227825Stheraven _LIBCPP_INLINE_VISIBILITY 2165250514Sdim typename enable_if 2166250514Sdim < 2167250514Sdim is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type, 2168250514Sdim result_type>::value, 2169250514Sdim result_type 2170250514Sdim >::type 2171227825Stheraven operator()(_Args&& ...__args) const 2172227825Stheraven { 2173227825Stheraven return base::operator()(_VSTD::forward<_Args>(__args)...); 2174227825Stheraven } 2175227825Stheraven}; 2176227825Stheraven 2177232950Stheraventemplate<class _Rp, class _Fp, class ..._BoundArgs> 2178232950Stheravenstruct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; 2179227825Stheraven 2180232950Stheraventemplate<class _Fp, class ..._BoundArgs> 2181227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2182232950Stheraven__bind<_Fp, _BoundArgs...> 2183232950Stheravenbind(_Fp&& __f, _BoundArgs&&... __bound_args) 2184227825Stheraven{ 2185232950Stheraven typedef __bind<_Fp, _BoundArgs...> type; 2186232950Stheraven return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); 2187227825Stheraven} 2188227825Stheraven 2189232950Stheraventemplate<class _Rp, class _Fp, class ..._BoundArgs> 2190227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 2191232950Stheraven__bind_r<_Rp, _Fp, _BoundArgs...> 2192232950Stheravenbind(_Fp&& __f, _BoundArgs&&... __bound_args) 2193227825Stheraven{ 2194232950Stheraven typedef __bind_r<_Rp, _Fp, _BoundArgs...> type; 2195232950Stheraven return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); 2196227825Stheraven} 2197227825Stheraven 2198227825Stheraven#endif // _LIBCPP_HAS_NO_VARIADICS 2199227825Stheraven 2200227825Stheraventemplate <> 2201262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<bool> 2202227825Stheraven : public unary_function<bool, size_t> 2203227825Stheraven{ 2204227825Stheraven _LIBCPP_INLINE_VISIBILITY 2205227825Stheraven size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2206227825Stheraven}; 2207227825Stheraven 2208227825Stheraventemplate <> 2209262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<char> 2210227825Stheraven : public unary_function<char, size_t> 2211227825Stheraven{ 2212227825Stheraven _LIBCPP_INLINE_VISIBILITY 2213227825Stheraven size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2214227825Stheraven}; 2215227825Stheraven 2216227825Stheraventemplate <> 2217262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<signed char> 2218227825Stheraven : public unary_function<signed char, size_t> 2219227825Stheraven{ 2220227825Stheraven _LIBCPP_INLINE_VISIBILITY 2221227825Stheraven size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2222227825Stheraven}; 2223227825Stheraven 2224227825Stheraventemplate <> 2225262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned char> 2226227825Stheraven : public unary_function<unsigned char, size_t> 2227227825Stheraven{ 2228227825Stheraven _LIBCPP_INLINE_VISIBILITY 2229227825Stheraven size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2230227825Stheraven}; 2231227825Stheraven 2232227825Stheraven#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 2233227825Stheraven 2234227825Stheraventemplate <> 2235262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<char16_t> 2236227825Stheraven : public unary_function<char16_t, size_t> 2237227825Stheraven{ 2238227825Stheraven _LIBCPP_INLINE_VISIBILITY 2239227825Stheraven size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2240227825Stheraven}; 2241227825Stheraven 2242227825Stheraventemplate <> 2243262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<char32_t> 2244227825Stheraven : public unary_function<char32_t, size_t> 2245227825Stheraven{ 2246227825Stheraven _LIBCPP_INLINE_VISIBILITY 2247227825Stheraven size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2248227825Stheraven}; 2249227825Stheraven 2250227825Stheraven#endif // _LIBCPP_HAS_NO_UNICODE_CHARS 2251227825Stheraven 2252227825Stheraventemplate <> 2253262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<wchar_t> 2254227825Stheraven : public unary_function<wchar_t, size_t> 2255227825Stheraven{ 2256227825Stheraven _LIBCPP_INLINE_VISIBILITY 2257227825Stheraven size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2258227825Stheraven}; 2259227825Stheraven 2260227825Stheraventemplate <> 2261262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<short> 2262227825Stheraven : public unary_function<short, size_t> 2263227825Stheraven{ 2264227825Stheraven _LIBCPP_INLINE_VISIBILITY 2265227825Stheraven size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2266227825Stheraven}; 2267227825Stheraven 2268227825Stheraventemplate <> 2269262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned short> 2270227825Stheraven : public unary_function<unsigned short, size_t> 2271227825Stheraven{ 2272227825Stheraven _LIBCPP_INLINE_VISIBILITY 2273227825Stheraven size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2274227825Stheraven}; 2275227825Stheraven 2276227825Stheraventemplate <> 2277262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<int> 2278227825Stheraven : public unary_function<int, size_t> 2279227825Stheraven{ 2280227825Stheraven _LIBCPP_INLINE_VISIBILITY 2281227825Stheraven size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2282227825Stheraven}; 2283227825Stheraven 2284227825Stheraventemplate <> 2285262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned int> 2286227825Stheraven : public unary_function<unsigned int, size_t> 2287227825Stheraven{ 2288227825Stheraven _LIBCPP_INLINE_VISIBILITY 2289227825Stheraven size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2290227825Stheraven}; 2291227825Stheraven 2292227825Stheraventemplate <> 2293262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<long> 2294227825Stheraven : public unary_function<long, size_t> 2295227825Stheraven{ 2296227825Stheraven _LIBCPP_INLINE_VISIBILITY 2297227825Stheraven size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2298227825Stheraven}; 2299227825Stheraven 2300227825Stheraventemplate <> 2301262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long> 2302227825Stheraven : public unary_function<unsigned long, size_t> 2303227825Stheraven{ 2304227825Stheraven _LIBCPP_INLINE_VISIBILITY 2305227825Stheraven size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 2306227825Stheraven}; 2307227825Stheraven 2308227825Stheraventemplate <> 2309262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<long long> 2310232950Stheraven : public __scalar_hash<long long> 2311227825Stheraven{ 2312227825Stheraven}; 2313227825Stheraven 2314227825Stheraventemplate <> 2315262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long long> 2316232950Stheraven : public __scalar_hash<unsigned long long> 2317227825Stheraven{ 2318227825Stheraven}; 2319227825Stheraven 2320227825Stheraventemplate <> 2321262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<float> 2322232950Stheraven : public __scalar_hash<float> 2323227825Stheraven{ 2324227825Stheraven _LIBCPP_INLINE_VISIBILITY 2325227825Stheraven size_t operator()(float __v) const _NOEXCEPT 2326227825Stheraven { 2327232950Stheraven // -0.0 and 0.0 should return same hash 2328232950Stheraven if (__v == 0) 2329232950Stheraven return 0; 2330232950Stheraven return __scalar_hash<float>::operator()(__v); 2331227825Stheraven } 2332227825Stheraven}; 2333227825Stheraven 2334227825Stheraventemplate <> 2335262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<double> 2336232950Stheraven : public __scalar_hash<double> 2337227825Stheraven{ 2338227825Stheraven _LIBCPP_INLINE_VISIBILITY 2339227825Stheraven size_t operator()(double __v) const _NOEXCEPT 2340227825Stheraven { 2341232950Stheraven // -0.0 and 0.0 should return same hash 2342232950Stheraven if (__v == 0) 2343232950Stheraven return 0; 2344232950Stheraven return __scalar_hash<double>::operator()(__v); 2345227825Stheraven } 2346227825Stheraven}; 2347227825Stheraven 2348227825Stheraventemplate <> 2349262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<long double> 2350232950Stheraven : public __scalar_hash<long double> 2351227825Stheraven{ 2352227825Stheraven _LIBCPP_INLINE_VISIBILITY 2353227825Stheraven size_t operator()(long double __v) const _NOEXCEPT 2354227825Stheraven { 2355232950Stheraven // -0.0 and 0.0 should return same hash 2356227825Stheraven if (__v == 0) 2357227825Stheraven return 0; 2358232950Stheraven#if defined(__i386__) 2359232950Stheraven // Zero out padding bits 2360232950Stheraven union 2361232950Stheraven { 2362232950Stheraven long double __t; 2363232950Stheraven struct 2364232950Stheraven { 2365232950Stheraven size_t __a; 2366232950Stheraven size_t __b; 2367232950Stheraven size_t __c; 2368232950Stheraven size_t __d; 2369232950Stheraven }; 2370232950Stheraven } __u; 2371232950Stheraven __u.__a = 0; 2372232950Stheraven __u.__b = 0; 2373232950Stheraven __u.__c = 0; 2374232950Stheraven __u.__d = 0; 2375232950Stheraven __u.__t = __v; 2376232950Stheraven return __u.__a ^ __u.__b ^ __u.__c ^ __u.__d; 2377232950Stheraven#elif defined(__x86_64__) 2378232950Stheraven // Zero out padding bits 2379232950Stheraven union 2380232950Stheraven { 2381232950Stheraven long double __t; 2382232950Stheraven struct 2383232950Stheraven { 2384232950Stheraven size_t __a; 2385232950Stheraven size_t __b; 2386232950Stheraven }; 2387232950Stheraven } __u; 2388232950Stheraven __u.__a = 0; 2389232950Stheraven __u.__b = 0; 2390232950Stheraven __u.__t = __v; 2391232950Stheraven return __u.__a ^ __u.__b; 2392232950Stheraven#else 2393232950Stheraven return __scalar_hash<long double>::operator()(__v); 2394232950Stheraven#endif 2395227825Stheraven } 2396227825Stheraven}; 2397227825Stheraven 2398262801Sdim#if _LIBCPP_STD_VER > 11 2399262801Sdimtemplate <class _Tp> 2400262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash 2401262801Sdim : public unary_function<_Tp, size_t> 2402262801Sdim{ 2403262801Sdim static_assert(is_enum<_Tp>::value, "This hash only works for enumeration types"); 2404262801Sdim 2405262801Sdim _LIBCPP_INLINE_VISIBILITY 2406262801Sdim size_t operator()(_Tp __v) const _NOEXCEPT 2407262801Sdim { 2408262801Sdim typedef typename underlying_type<_Tp>::type type; 2409262801Sdim return hash<type>{}(static_cast<type>(__v)); 2410262801Sdim } 2411262801Sdim}; 2412262801Sdim#endif 2413262801Sdim 2414227825Stheraven// struct hash<T*> in <memory> 2415227825Stheraven 2416227825Stheraven_LIBCPP_END_NAMESPACE_STD 2417227825Stheraven 2418227825Stheraven#endif // _LIBCPP_FUNCTIONAL 2419