1*700637cbSDimitry Andric// -*- C++ -*- 2*700637cbSDimitry Andric//===----------------------------------------------------------------------===// 3*700637cbSDimitry Andric// 4*700637cbSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5*700637cbSDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 6*700637cbSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7*700637cbSDimitry Andric// 8*700637cbSDimitry Andric//===----------------------------------------------------------------------===// 9*700637cbSDimitry Andric 10*700637cbSDimitry Andric#ifndef _LIBCPP___CXX03_FUNCTIONAL 11*700637cbSDimitry Andric#define _LIBCPP___CXX03_FUNCTIONAL 12*700637cbSDimitry Andric 13*700637cbSDimitry Andric/* 14*700637cbSDimitry Andric functional synopsis 15*700637cbSDimitry Andric 16*700637cbSDimitry Andricnamespace std 17*700637cbSDimitry Andric{ 18*700637cbSDimitry Andric 19*700637cbSDimitry Andrictemplate <class Arg, class Result> 20*700637cbSDimitry Andricstruct unary_function 21*700637cbSDimitry Andric{ 22*700637cbSDimitry Andric typedef Arg argument_type; 23*700637cbSDimitry Andric typedef Result result_type; 24*700637cbSDimitry Andric}; 25*700637cbSDimitry Andric 26*700637cbSDimitry Andrictemplate <class Arg1, class Arg2, class Result> 27*700637cbSDimitry Andricstruct binary_function 28*700637cbSDimitry Andric{ 29*700637cbSDimitry Andric typedef Arg1 first_argument_type; 30*700637cbSDimitry Andric typedef Arg2 second_argument_type; 31*700637cbSDimitry Andric typedef Result result_type; 32*700637cbSDimitry Andric}; 33*700637cbSDimitry Andric 34*700637cbSDimitry Andrictemplate <class T> 35*700637cbSDimitry Andricclass reference_wrapper 36*700637cbSDimitry Andric : public unary_function<T1, R> // if wrapping a unary functor 37*700637cbSDimitry Andric : public binary_function<T1, T2, R> // if wrapping a binary functor 38*700637cbSDimitry Andric{ 39*700637cbSDimitry Andricpublic: 40*700637cbSDimitry Andric // types 41*700637cbSDimitry Andric typedef T type; 42*700637cbSDimitry Andric typedef see below result_type; // Not always defined 43*700637cbSDimitry Andric 44*700637cbSDimitry Andric // construct/copy/destroy 45*700637cbSDimitry Andric template<class U> 46*700637cbSDimitry Andric constexpr reference_wrapper(U&&); // constexpr since C++20 47*700637cbSDimitry Andric constexpr reference_wrapper(const reference_wrapper<T>& x) noexcept; // constexpr since C++20 48*700637cbSDimitry Andric 49*700637cbSDimitry Andric // assignment 50*700637cbSDimitry Andric constexpr reference_wrapper& 51*700637cbSDimitry Andric operator=(const reference_wrapper<T>& x) noexcept; // constexpr since C++20 52*700637cbSDimitry Andric 53*700637cbSDimitry Andric // access 54*700637cbSDimitry Andric constexpr operator T& () const noexcept; // constexpr since C++20 55*700637cbSDimitry Andric constexpr T& get() const noexcept; // constexpr since C++20 56*700637cbSDimitry Andric 57*700637cbSDimitry Andric // invoke 58*700637cbSDimitry Andric template <class... ArgTypes> 59*700637cbSDimitry Andric constexpr typename result_of<T&(ArgTypes&&...)>::type // constexpr since C++20 60*700637cbSDimitry Andric operator() (ArgTypes&&...) const 61*700637cbSDimitry Andric noexcept(is_nothrow_invocable_v<T&, ArgTypes...>); // noexcept since C++17 62*700637cbSDimitry Andric}; 63*700637cbSDimitry Andric 64*700637cbSDimitry Andrictemplate <class T> 65*700637cbSDimitry Andric reference_wrapper(T&) -> reference_wrapper<T>; 66*700637cbSDimitry Andric 67*700637cbSDimitry Andrictemplate <class T> reference_wrapper<T> ref(T& t) noexcept; 68*700637cbSDimitry Andrictemplate <class T> void ref(const T&& t) = delete; 69*700637cbSDimitry Andrictemplate <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept; 70*700637cbSDimitry Andric 71*700637cbSDimitry Andrictemplate <class T> reference_wrapper<const T> cref(const T& t) noexcept; 72*700637cbSDimitry Andrictemplate <class T> void cref(const T&& t) = delete; 73*700637cbSDimitry Andrictemplate <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept; 74*700637cbSDimitry Andric 75*700637cbSDimitry Andrictemplate <class T> struct unwrap_reference; // since C++20 76*700637cbSDimitry Andrictemplate <class T> struct unwrap_ref_decay : unwrap_reference<decay_t<T>> { }; // since C++20 77*700637cbSDimitry Andrictemplate <class T> using unwrap_reference_t = typename unwrap_reference<T>::type; // since C++20 78*700637cbSDimitry Andrictemplate <class T> using unwrap_ref_decay_t = typename unwrap_ref_decay<T>::type; // since C++20 79*700637cbSDimitry Andric 80*700637cbSDimitry Andric// [refwrap.comparisons], comparisons 81*700637cbSDimitry Andricfriend constexpr bool operator==(reference_wrapper, reference_wrapper); // Since C++26 82*700637cbSDimitry Andricfriend constexpr bool operator==(reference_wrapper, const T&); // Since C++26 83*700637cbSDimitry Andricfriend constexpr bool operator==(reference_wrapper, reference_wrapper<const T>); // Since C++26 84*700637cbSDimitry Andric 85*700637cbSDimitry Andricfriend constexpr auto operator<=>(reference_wrapper, reference_wrapper); // Since C++26 86*700637cbSDimitry Andricfriend constexpr auto operator<=>(reference_wrapper, const T&); // Since C++26 87*700637cbSDimitry Andricfriend constexpr auto operator<=>(reference_wrapper, reference_wrapper<const T>); // Since C++26 88*700637cbSDimitry Andric 89*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 90*700637cbSDimitry Andricstruct plus { 91*700637cbSDimitry Andric T operator()(const T& x, const T& y) const; 92*700637cbSDimitry Andric}; 93*700637cbSDimitry Andric 94*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 95*700637cbSDimitry Andricstruct minus { 96*700637cbSDimitry Andric T operator()(const T& x, const T& y) const; 97*700637cbSDimitry Andric}; 98*700637cbSDimitry Andric 99*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 100*700637cbSDimitry Andricstruct multiplies { 101*700637cbSDimitry Andric T operator()(const T& x, const T& y) const; 102*700637cbSDimitry Andric}; 103*700637cbSDimitry Andric 104*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 105*700637cbSDimitry Andricstruct divides { 106*700637cbSDimitry Andric T operator()(const T& x, const T& y) const; 107*700637cbSDimitry Andric}; 108*700637cbSDimitry Andric 109*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 110*700637cbSDimitry Andricstruct modulus { 111*700637cbSDimitry Andric T operator()(const T& x, const T& y) const; 112*700637cbSDimitry Andric}; 113*700637cbSDimitry Andric 114*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 115*700637cbSDimitry Andricstruct negate { 116*700637cbSDimitry Andric T operator()(const T& x) const; 117*700637cbSDimitry Andric}; 118*700637cbSDimitry Andric 119*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 120*700637cbSDimitry Andricstruct equal_to { 121*700637cbSDimitry Andric bool operator()(const T& x, const T& y) const; 122*700637cbSDimitry Andric}; 123*700637cbSDimitry Andric 124*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 125*700637cbSDimitry Andricstruct not_equal_to { 126*700637cbSDimitry Andric bool operator()(const T& x, const T& y) const; 127*700637cbSDimitry Andric}; 128*700637cbSDimitry Andric 129*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 130*700637cbSDimitry Andricstruct greater { 131*700637cbSDimitry Andric bool operator()(const T& x, const T& y) const; 132*700637cbSDimitry Andric}; 133*700637cbSDimitry Andric 134*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 135*700637cbSDimitry Andricstruct less { 136*700637cbSDimitry Andric bool operator()(const T& x, const T& y) const; 137*700637cbSDimitry Andric}; 138*700637cbSDimitry Andric 139*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 140*700637cbSDimitry Andricstruct greater_equal { 141*700637cbSDimitry Andric bool operator()(const T& x, const T& y) const; 142*700637cbSDimitry Andric}; 143*700637cbSDimitry Andric 144*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 145*700637cbSDimitry Andricstruct less_equal { 146*700637cbSDimitry Andric bool operator()(const T& x, const T& y) const; 147*700637cbSDimitry Andric}; 148*700637cbSDimitry Andric 149*700637cbSDimitry Andric// [comparisons.three.way], class compare_three_way 150*700637cbSDimitry Andricstruct compare_three_way; 151*700637cbSDimitry Andric 152*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 153*700637cbSDimitry Andricstruct logical_and { 154*700637cbSDimitry Andric bool operator()(const T& x, const T& y) const; 155*700637cbSDimitry Andric}; 156*700637cbSDimitry Andric 157*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 158*700637cbSDimitry Andricstruct logical_or { 159*700637cbSDimitry Andric bool operator()(const T& x, const T& y) const; 160*700637cbSDimitry Andric}; 161*700637cbSDimitry Andric 162*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 163*700637cbSDimitry Andricstruct logical_not { 164*700637cbSDimitry Andric bool operator()(const T& x) const; 165*700637cbSDimitry Andric}; 166*700637cbSDimitry Andric 167*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 168*700637cbSDimitry Andricstruct bit_and { 169*700637cbSDimitry Andric T operator()(const T& x, const T& y) const; 170*700637cbSDimitry Andric}; 171*700637cbSDimitry Andric 172*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 173*700637cbSDimitry Andricstruct bit_or { 174*700637cbSDimitry Andric T operator()(const T& x, const T& y) const; 175*700637cbSDimitry Andric}; 176*700637cbSDimitry Andric 177*700637cbSDimitry Andrictemplate <class T> // <class T=void> in C++14 178*700637cbSDimitry Andricstruct bit_xor { 179*700637cbSDimitry Andric T operator()(const T& x, const T& y) const; 180*700637cbSDimitry Andric}; 181*700637cbSDimitry Andric 182*700637cbSDimitry Andrictemplate <class T=void> // C++14 183*700637cbSDimitry Andricstruct bit_not { 184*700637cbSDimitry Andric T operator()(const T& x) const; 185*700637cbSDimitry Andric}; 186*700637cbSDimitry Andric 187*700637cbSDimitry Andricstruct identity; // C++20 188*700637cbSDimitry Andric 189*700637cbSDimitry Andrictemplate <class Predicate> 190*700637cbSDimitry Andricclass unary_negate // deprecated in C++17, removed in C++20 191*700637cbSDimitry Andric : public unary_function<typename Predicate::argument_type, bool> 192*700637cbSDimitry Andric{ 193*700637cbSDimitry Andricpublic: 194*700637cbSDimitry Andric explicit unary_negate(const Predicate& pred); 195*700637cbSDimitry Andric bool operator()(const typename Predicate::argument_type& x) const; 196*700637cbSDimitry Andric}; 197*700637cbSDimitry Andric 198*700637cbSDimitry Andrictemplate <class Predicate> // deprecated in C++17, removed in C++20 199*700637cbSDimitry Andricunary_negate<Predicate> not1(const Predicate& pred); 200*700637cbSDimitry Andric 201*700637cbSDimitry Andrictemplate <class Predicate> 202*700637cbSDimitry Andricclass binary_negate // deprecated in C++17, removed in C++20 203*700637cbSDimitry Andric : public binary_function<typename Predicate::first_argument_type, 204*700637cbSDimitry Andric typename Predicate::second_argument_type, 205*700637cbSDimitry Andric bool> 206*700637cbSDimitry Andric{ 207*700637cbSDimitry Andricpublic: 208*700637cbSDimitry Andric explicit binary_negate(const Predicate& pred); 209*700637cbSDimitry Andric bool operator()(const typename Predicate::first_argument_type& x, 210*700637cbSDimitry Andric const typename Predicate::second_argument_type& y) const; 211*700637cbSDimitry Andric}; 212*700637cbSDimitry Andric 213*700637cbSDimitry Andrictemplate <class Predicate> // deprecated in C++17, removed in C++20 214*700637cbSDimitry Andricbinary_negate<Predicate> not2(const Predicate& pred); 215*700637cbSDimitry Andric 216*700637cbSDimitry Andrictemplate <class F> 217*700637cbSDimitry Andricconstexpr unspecified not_fn(F&& f); // C++17, constexpr in C++20 218*700637cbSDimitry Andric 219*700637cbSDimitry Andric// [func.bind.partial], function templates bind_front and bind_back 220*700637cbSDimitry Andrictemplate<class F, class... Args> 221*700637cbSDimitry Andric constexpr unspecified bind_front(F&&, Args&&...); // C++20 222*700637cbSDimitry Andrictemplate<class F, class... Args> 223*700637cbSDimitry Andric constexpr unspecified bind_back(F&&, Args&&...); // C++23 224*700637cbSDimitry Andric 225*700637cbSDimitry Andrictemplate<class T> struct is_bind_expression; 226*700637cbSDimitry Andrictemplate<class T> struct is_placeholder; 227*700637cbSDimitry Andric 228*700637cbSDimitry Andric // See C++14 20.9.9, Function object binders 229*700637cbSDimitry Andrictemplate <class T> inline constexpr bool is_bind_expression_v 230*700637cbSDimitry Andric = is_bind_expression<T>::value; // C++17 231*700637cbSDimitry Andrictemplate <class T> inline constexpr int is_placeholder_v 232*700637cbSDimitry Andric = is_placeholder<T>::value; // C++17 233*700637cbSDimitry Andric 234*700637cbSDimitry Andric 235*700637cbSDimitry Andrictemplate<class Fn, class... BoundArgs> 236*700637cbSDimitry Andric constexpr unspecified bind(Fn&&, BoundArgs&&...); // constexpr in C++20 237*700637cbSDimitry Andrictemplate<class R, class Fn, class... BoundArgs> 238*700637cbSDimitry Andric constexpr unspecified bind(Fn&&, BoundArgs&&...); // constexpr in C++20 239*700637cbSDimitry Andric 240*700637cbSDimitry Andric// [func.invoke] 241*700637cbSDimitry Andrictemplate<class F, class... Args> 242*700637cbSDimitry Andric constexpr // constexpr in C++20 243*700637cbSDimitry Andric invoke_result_t<F, Args...> invoke(F&& f, Args&&... args) // C++17 244*700637cbSDimitry Andric noexcept(is_nothrow_invocable_v<F, Args...>); 245*700637cbSDimitry Andric 246*700637cbSDimitry Andrictemplate<class R, class F, class... Args> 247*700637cbSDimitry Andric constexpr R invoke_r(F&& f, Args&&... args) // C++23 248*700637cbSDimitry Andric noexcept(is_nothrow_invocable_r_v<R, F, Args...>); 249*700637cbSDimitry Andric 250*700637cbSDimitry Andricnamespace placeholders { 251*700637cbSDimitry Andric // M is the implementation-defined number of placeholders 252*700637cbSDimitry Andric extern unspecified _1; 253*700637cbSDimitry Andric extern unspecified _2; 254*700637cbSDimitry Andric . 255*700637cbSDimitry Andric . 256*700637cbSDimitry Andric . 257*700637cbSDimitry Andric extern unspecified _Mp; 258*700637cbSDimitry Andric} 259*700637cbSDimitry Andric 260*700637cbSDimitry Andrictemplate <class Operation> 261*700637cbSDimitry Andricclass binder1st // deprecated in C++11, removed in C++17 262*700637cbSDimitry Andric : public unary_function<typename Operation::second_argument_type, 263*700637cbSDimitry Andric typename Operation::result_type> 264*700637cbSDimitry Andric{ 265*700637cbSDimitry Andricprotected: 266*700637cbSDimitry Andric Operation op; 267*700637cbSDimitry Andric typename Operation::first_argument_type value; 268*700637cbSDimitry Andricpublic: 269*700637cbSDimitry Andric binder1st(const Operation& x, const typename Operation::first_argument_type y); 270*700637cbSDimitry Andric typename Operation::result_type operator()( typename Operation::second_argument_type& x) const; 271*700637cbSDimitry Andric typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const; 272*700637cbSDimitry Andric}; 273*700637cbSDimitry Andric 274*700637cbSDimitry Andrictemplate <class Operation, class T> 275*700637cbSDimitry Andricbinder1st<Operation> bind1st(const Operation& op, const T& x); // deprecated in C++11, removed in C++17 276*700637cbSDimitry Andric 277*700637cbSDimitry Andrictemplate <class Operation> 278*700637cbSDimitry Andricclass binder2nd // deprecated in C++11, removed in C++17 279*700637cbSDimitry Andric : public unary_function<typename Operation::first_argument_type, 280*700637cbSDimitry Andric typename Operation::result_type> 281*700637cbSDimitry Andric{ 282*700637cbSDimitry Andricprotected: 283*700637cbSDimitry Andric Operation op; 284*700637cbSDimitry Andric typename Operation::second_argument_type value; 285*700637cbSDimitry Andricpublic: 286*700637cbSDimitry Andric binder2nd(const Operation& x, const typename Operation::second_argument_type y); 287*700637cbSDimitry Andric typename Operation::result_type operator()( typename Operation::first_argument_type& x) const; 288*700637cbSDimitry Andric typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const; 289*700637cbSDimitry Andric}; 290*700637cbSDimitry Andric 291*700637cbSDimitry Andrictemplate <class Operation, class T> 292*700637cbSDimitry Andricbinder2nd<Operation> bind2nd(const Operation& op, const T& x); // deprecated in C++11, removed in C++17 293*700637cbSDimitry Andric 294*700637cbSDimitry Andrictemplate <class Arg, class Result> // deprecated in C++11, removed in C++17 295*700637cbSDimitry Andricclass pointer_to_unary_function : public unary_function<Arg, Result> 296*700637cbSDimitry Andric{ 297*700637cbSDimitry Andricpublic: 298*700637cbSDimitry Andric explicit pointer_to_unary_function(Result (*f)(Arg)); 299*700637cbSDimitry Andric Result operator()(Arg x) const; 300*700637cbSDimitry Andric}; 301*700637cbSDimitry Andric 302*700637cbSDimitry Andrictemplate <class Arg, class Result> 303*700637cbSDimitry Andricpointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg)); // deprecated in C++11, removed in C++17 304*700637cbSDimitry Andric 305*700637cbSDimitry Andrictemplate <class Arg1, class Arg2, class Result> // deprecated in C++11, removed in C++17 306*700637cbSDimitry Andricclass pointer_to_binary_function : public binary_function<Arg1, Arg2, Result> 307*700637cbSDimitry Andric{ 308*700637cbSDimitry Andricpublic: 309*700637cbSDimitry Andric explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)); 310*700637cbSDimitry Andric Result operator()(Arg1 x, Arg2 y) const; 311*700637cbSDimitry Andric}; 312*700637cbSDimitry Andric 313*700637cbSDimitry Andrictemplate <class Arg1, class Arg2, class Result> 314*700637cbSDimitry Andricpointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2)); // deprecated in C++11, removed in C++17 315*700637cbSDimitry Andric 316*700637cbSDimitry Andrictemplate<class S, class T> // deprecated in C++11, removed in C++17 317*700637cbSDimitry Andricclass mem_fun_t : public unary_function<T*, S> 318*700637cbSDimitry Andric{ 319*700637cbSDimitry Andricpublic: 320*700637cbSDimitry Andric explicit mem_fun_t(S (T::*p)()); 321*700637cbSDimitry Andric S operator()(T* p) const; 322*700637cbSDimitry Andric}; 323*700637cbSDimitry Andric 324*700637cbSDimitry Andrictemplate<class S, class T, class A> 325*700637cbSDimitry Andricclass mem_fun1_t : public binary_function<T*, A, S> // deprecated in C++11, removed in C++17 326*700637cbSDimitry Andric{ 327*700637cbSDimitry Andricpublic: 328*700637cbSDimitry Andric explicit mem_fun1_t(S (T::*p)(A)); 329*700637cbSDimitry Andric S operator()(T* p, A x) const; 330*700637cbSDimitry Andric}; 331*700637cbSDimitry Andric 332*700637cbSDimitry Andrictemplate<class S, class T> mem_fun_t<S,T> mem_fun(S (T::*f)()); // deprecated in C++11, removed in C++17 333*700637cbSDimitry Andrictemplate<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A)); // deprecated in C++11, removed in C++17 334*700637cbSDimitry Andric 335*700637cbSDimitry Andrictemplate<class S, class T> 336*700637cbSDimitry Andricclass mem_fun_ref_t : public unary_function<T, S> // deprecated in C++11, removed in C++17 337*700637cbSDimitry Andric{ 338*700637cbSDimitry Andricpublic: 339*700637cbSDimitry Andric explicit mem_fun_ref_t(S (T::*p)()); 340*700637cbSDimitry Andric S operator()(T& p) const; 341*700637cbSDimitry Andric}; 342*700637cbSDimitry Andric 343*700637cbSDimitry Andrictemplate<class S, class T, class A> 344*700637cbSDimitry Andricclass mem_fun1_ref_t : public binary_function<T, A, S> // deprecated in C++11, removed in C++17 345*700637cbSDimitry Andric{ 346*700637cbSDimitry Andricpublic: 347*700637cbSDimitry Andric explicit mem_fun1_ref_t(S (T::*p)(A)); 348*700637cbSDimitry Andric S operator()(T& p, A x) const; 349*700637cbSDimitry Andric}; 350*700637cbSDimitry Andric 351*700637cbSDimitry Andrictemplate<class S, class T> 352*700637cbSDimitry Andricmem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)()); // deprecated in C++11, removed in C++17 353*700637cbSDimitry Andrictemplate<class S, class T, class A> 354*700637cbSDimitry Andricmem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A)); // deprecated in C++11, removed in C++17 355*700637cbSDimitry Andric 356*700637cbSDimitry Andrictemplate <class S, class T> 357*700637cbSDimitry Andricclass const_mem_fun_t : public unary_function<const T*, S> // deprecated in C++11, removed in C++17 358*700637cbSDimitry Andric{ 359*700637cbSDimitry Andricpublic: 360*700637cbSDimitry Andric explicit const_mem_fun_t(S (T::*p)() const); 361*700637cbSDimitry Andric S operator()(const T* p) const; 362*700637cbSDimitry Andric}; 363*700637cbSDimitry Andric 364*700637cbSDimitry Andrictemplate <class S, class T, class A> 365*700637cbSDimitry Andricclass const_mem_fun1_t : public binary_function<const T*, A, S> // deprecated in C++11, removed in C++17 366*700637cbSDimitry Andric{ 367*700637cbSDimitry Andricpublic: 368*700637cbSDimitry Andric explicit const_mem_fun1_t(S (T::*p)(A) const); 369*700637cbSDimitry Andric S operator()(const T* p, A x) const; 370*700637cbSDimitry Andric}; 371*700637cbSDimitry Andric 372*700637cbSDimitry Andrictemplate <class S, class T> 373*700637cbSDimitry Andricconst_mem_fun_t<S,T> mem_fun(S (T::*f)() const); // deprecated in C++11, removed in C++17 374*700637cbSDimitry Andrictemplate <class S, class T, class A> 375*700637cbSDimitry Andricconst_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const); // deprecated in C++11, removed in C++17 376*700637cbSDimitry Andric 377*700637cbSDimitry Andrictemplate <class S, class T> 378*700637cbSDimitry Andricclass const_mem_fun_ref_t : public unary_function<T, S> // deprecated in C++11, removed in C++17 379*700637cbSDimitry Andric{ 380*700637cbSDimitry Andricpublic: 381*700637cbSDimitry Andric explicit const_mem_fun_ref_t(S (T::*p)() const); 382*700637cbSDimitry Andric S operator()(const T& p) const; 383*700637cbSDimitry Andric}; 384*700637cbSDimitry Andric 385*700637cbSDimitry Andrictemplate <class S, class T, class A> 386*700637cbSDimitry Andricclass const_mem_fun1_ref_t : public binary_function<T, A, S> // deprecated in C++11, removed in C++17 387*700637cbSDimitry Andric{ 388*700637cbSDimitry Andricpublic: 389*700637cbSDimitry Andric explicit const_mem_fun1_ref_t(S (T::*p)(A) const); 390*700637cbSDimitry Andric S operator()(const T& p, A x) const; 391*700637cbSDimitry Andric}; 392*700637cbSDimitry Andric 393*700637cbSDimitry Andrictemplate <class S, class T> 394*700637cbSDimitry Andricconst_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const); // deprecated in C++11, removed in C++17 395*700637cbSDimitry Andrictemplate <class S, class T, class A> 396*700637cbSDimitry Andricconst_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const); // deprecated in C++11, removed in C++17 397*700637cbSDimitry Andric 398*700637cbSDimitry Andrictemplate<class R, class T> constexpr unspecified mem_fn(R T::*); // constexpr in C++20 399*700637cbSDimitry Andric 400*700637cbSDimitry Andricclass bad_function_call 401*700637cbSDimitry Andric : public exception 402*700637cbSDimitry Andric{ 403*700637cbSDimitry Andric}; 404*700637cbSDimitry Andric 405*700637cbSDimitry Andrictemplate<class> class function; // undefined 406*700637cbSDimitry Andric 407*700637cbSDimitry Andrictemplate<class R, class... ArgTypes> 408*700637cbSDimitry Andricclass function<R(ArgTypes...)> 409*700637cbSDimitry Andric : public unary_function<T1, R> // iff sizeof...(ArgTypes) == 1 and 410*700637cbSDimitry Andric // ArgTypes contains T1 411*700637cbSDimitry Andric : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and 412*700637cbSDimitry Andric // ArgTypes contains T1 and T2 413*700637cbSDimitry Andric{ 414*700637cbSDimitry Andricpublic: 415*700637cbSDimitry Andric typedef R result_type; 416*700637cbSDimitry Andric 417*700637cbSDimitry Andric // construct/copy/destroy: 418*700637cbSDimitry Andric function() noexcept; 419*700637cbSDimitry Andric function(nullptr_t) noexcept; 420*700637cbSDimitry Andric function(const function&); 421*700637cbSDimitry Andric function(function&&) noexcept; 422*700637cbSDimitry Andric template<class F> 423*700637cbSDimitry Andric function(F); 424*700637cbSDimitry Andric template<Allocator Alloc> 425*700637cbSDimitry Andric function(allocator_arg_t, const Alloc&) noexcept; // removed in C++17 426*700637cbSDimitry Andric template<Allocator Alloc> 427*700637cbSDimitry Andric function(allocator_arg_t, const Alloc&, nullptr_t) noexcept; // removed in C++17 428*700637cbSDimitry Andric template<Allocator Alloc> 429*700637cbSDimitry Andric function(allocator_arg_t, const Alloc&, const function&); // removed in C++17 430*700637cbSDimitry Andric template<Allocator Alloc> 431*700637cbSDimitry Andric function(allocator_arg_t, const Alloc&, function&&); // removed in C++17 432*700637cbSDimitry Andric template<class F, Allocator Alloc> 433*700637cbSDimitry Andric function(allocator_arg_t, const Alloc&, F); // removed in C++17 434*700637cbSDimitry Andric 435*700637cbSDimitry Andric function& operator=(const function&); 436*700637cbSDimitry Andric function& operator=(function&&) noexcept; 437*700637cbSDimitry Andric function& operator=(nullptr_t) noexcept; 438*700637cbSDimitry Andric template<class F> 439*700637cbSDimitry Andric function& operator=(F&&); 440*700637cbSDimitry Andric template<class F> 441*700637cbSDimitry Andric function& operator=(reference_wrapper<F>) noexcept; 442*700637cbSDimitry Andric 443*700637cbSDimitry Andric ~function(); 444*700637cbSDimitry Andric 445*700637cbSDimitry Andric // function modifiers: 446*700637cbSDimitry Andric void swap(function&) noexcept; 447*700637cbSDimitry Andric template<class F, class Alloc> 448*700637cbSDimitry Andric void assign(F&&, const Alloc&); // Removed in C++17 449*700637cbSDimitry Andric 450*700637cbSDimitry Andric // function capacity: 451*700637cbSDimitry Andric explicit operator bool() const noexcept; 452*700637cbSDimitry Andric 453*700637cbSDimitry Andric // function invocation: 454*700637cbSDimitry Andric R operator()(ArgTypes...) const; 455*700637cbSDimitry Andric 456*700637cbSDimitry Andric // function target access: 457*700637cbSDimitry Andric const std::type_info& target_type() const noexcept; 458*700637cbSDimitry Andric template <typename T> T* target() noexcept; 459*700637cbSDimitry Andric template <typename T> const T* target() const noexcept; 460*700637cbSDimitry Andric}; 461*700637cbSDimitry Andric 462*700637cbSDimitry Andric// Deduction guides 463*700637cbSDimitry Andrictemplate<class R, class ...Args> 464*700637cbSDimitry Andricfunction(R(*)(Args...)) -> function<R(Args...)>; // since C++17 465*700637cbSDimitry Andric 466*700637cbSDimitry Andrictemplate<class F> 467*700637cbSDimitry Andricfunction(F) -> function<see-below>; // since C++17 468*700637cbSDimitry Andric 469*700637cbSDimitry Andric// Null pointer comparisons: 470*700637cbSDimitry Andrictemplate <class R, class ... ArgTypes> 471*700637cbSDimitry Andric bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept; 472*700637cbSDimitry Andric 473*700637cbSDimitry Andrictemplate <class R, class ... ArgTypes> 474*700637cbSDimitry Andric bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept; // removed in C++20 475*700637cbSDimitry Andric 476*700637cbSDimitry Andrictemplate <class R, class ... ArgTypes> 477*700637cbSDimitry Andric bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept; // removed in C++20 478*700637cbSDimitry Andric 479*700637cbSDimitry Andrictemplate <class R, class ... ArgTypes> 480*700637cbSDimitry Andric bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept; // removed in C++20 481*700637cbSDimitry Andric 482*700637cbSDimitry Andric// specialized algorithms: 483*700637cbSDimitry Andrictemplate <class R, class ... ArgTypes> 484*700637cbSDimitry Andric void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept; 485*700637cbSDimitry Andric 486*700637cbSDimitry Andrictemplate <class T> struct hash; 487*700637cbSDimitry Andric 488*700637cbSDimitry Andrictemplate <> struct hash<bool>; 489*700637cbSDimitry Andrictemplate <> struct hash<char>; 490*700637cbSDimitry Andrictemplate <> struct hash<signed char>; 491*700637cbSDimitry Andrictemplate <> struct hash<unsigned char>; 492*700637cbSDimitry Andrictemplate <> struct hash<char8_t>; // since C++20 493*700637cbSDimitry Andrictemplate <> struct hash<char16_t>; 494*700637cbSDimitry Andrictemplate <> struct hash<char32_t>; 495*700637cbSDimitry Andrictemplate <> struct hash<wchar_t>; 496*700637cbSDimitry Andrictemplate <> struct hash<short>; 497*700637cbSDimitry Andrictemplate <> struct hash<unsigned short>; 498*700637cbSDimitry Andrictemplate <> struct hash<int>; 499*700637cbSDimitry Andrictemplate <> struct hash<unsigned int>; 500*700637cbSDimitry Andrictemplate <> struct hash<long>; 501*700637cbSDimitry Andrictemplate <> struct hash<long long>; 502*700637cbSDimitry Andrictemplate <> struct hash<unsigned long>; 503*700637cbSDimitry Andrictemplate <> struct hash<unsigned long long>; 504*700637cbSDimitry Andric 505*700637cbSDimitry Andrictemplate <> struct hash<float>; 506*700637cbSDimitry Andrictemplate <> struct hash<double>; 507*700637cbSDimitry Andrictemplate <> struct hash<long double>; 508*700637cbSDimitry Andric 509*700637cbSDimitry Andrictemplate<class T> struct hash<T*>; 510*700637cbSDimitry Andrictemplate <> struct hash<nullptr_t>; // C++17 511*700637cbSDimitry Andric 512*700637cbSDimitry Andricnamespace ranges { 513*700637cbSDimitry Andric // [range.cmp], concept-constrained comparisons 514*700637cbSDimitry Andric struct equal_to; 515*700637cbSDimitry Andric struct not_equal_to; 516*700637cbSDimitry Andric struct greater; 517*700637cbSDimitry Andric struct less; 518*700637cbSDimitry Andric struct greater_equal; 519*700637cbSDimitry Andric struct less_equal; 520*700637cbSDimitry Andric} 521*700637cbSDimitry Andric 522*700637cbSDimitry Andric} // std 523*700637cbSDimitry Andric 524*700637cbSDimitry AndricPOLICY: For non-variadic implementations, the number of arguments is limited 525*700637cbSDimitry Andric to 3. It is hoped that the need for non-variadic implementations 526*700637cbSDimitry Andric will be minimal. 527*700637cbSDimitry Andric 528*700637cbSDimitry Andric*/ 529*700637cbSDimitry Andric 530*700637cbSDimitry Andric#include <__cxx03/__config> 531*700637cbSDimitry Andric 532*700637cbSDimitry Andric#include <__cxx03/__functional/binary_function.h> 533*700637cbSDimitry Andric#include <__cxx03/__functional/binary_negate.h> 534*700637cbSDimitry Andric#include <__cxx03/__functional/bind.h> 535*700637cbSDimitry Andric#include <__cxx03/__functional/binder1st.h> 536*700637cbSDimitry Andric#include <__cxx03/__functional/binder2nd.h> 537*700637cbSDimitry Andric#include <__cxx03/__functional/hash.h> 538*700637cbSDimitry Andric#include <__cxx03/__functional/mem_fn.h> // TODO: deprecate 539*700637cbSDimitry Andric#include <__cxx03/__functional/mem_fun_ref.h> 540*700637cbSDimitry Andric#include <__cxx03/__functional/operations.h> 541*700637cbSDimitry Andric#include <__cxx03/__functional/pointer_to_binary_function.h> 542*700637cbSDimitry Andric#include <__cxx03/__functional/pointer_to_unary_function.h> 543*700637cbSDimitry Andric#include <__cxx03/__functional/reference_wrapper.h> 544*700637cbSDimitry Andric#include <__cxx03/__functional/unary_function.h> 545*700637cbSDimitry Andric#include <__cxx03/__functional/unary_negate.h> 546*700637cbSDimitry Andric 547*700637cbSDimitry Andric#include <__cxx03/version> 548*700637cbSDimitry Andric 549*700637cbSDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 550*700637cbSDimitry Andric# pragma GCC system_header 551*700637cbSDimitry Andric#endif 552*700637cbSDimitry Andric 553*700637cbSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) 554*700637cbSDimitry Andric# include <__cxx03/limits> 555*700637cbSDimitry Andric# include <__cxx03/new> 556*700637cbSDimitry Andric#endif 557*700637cbSDimitry Andric 558*700637cbSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) 559*700637cbSDimitry Andric# include <__cxx03/array> 560*700637cbSDimitry Andric# include <__cxx03/unordered_map> 561*700637cbSDimitry Andric# include <__cxx03/vector> 562*700637cbSDimitry Andric#endif 563*700637cbSDimitry Andric 564*700637cbSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) 565*700637cbSDimitry Andric# include <__cxx03/atomic> 566*700637cbSDimitry Andric# include <__cxx03/cstdlib> 567*700637cbSDimitry Andric# include <__cxx03/exception> 568*700637cbSDimitry Andric# include <__cxx03/iosfwd> 569*700637cbSDimitry Andric# include <__cxx03/memory> 570*700637cbSDimitry Andric# include <__cxx03/stdexcept> 571*700637cbSDimitry Andric# include <__cxx03/type_traits> 572*700637cbSDimitry Andric# include <__cxx03/typeinfo> 573*700637cbSDimitry Andric# include <__cxx03/utility> 574*700637cbSDimitry Andric#endif 575*700637cbSDimitry Andric 576*700637cbSDimitry Andric#endif // _LIBCPP___CXX03_FUNCTIONAL 577