1fe6060f1SDimitry Andric // -*- C++ -*- 2fe6060f1SDimitry Andric //===----------------------------------------------------------------------===// 3fe6060f1SDimitry Andric // 4fe6060f1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5fe6060f1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 6fe6060f1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7fe6060f1SDimitry Andric // 8fe6060f1SDimitry Andric //===----------------------------------------------------------------------===// 9fe6060f1SDimitry Andric 10fe6060f1SDimitry Andric #ifndef _LIBCPP___FUNCTIONAL_BIND_H 11fe6060f1SDimitry Andric #define _LIBCPP___FUNCTIONAL_BIND_H 12fe6060f1SDimitry Andric 13fe6060f1SDimitry Andric #include <__config> 14fe6060f1SDimitry Andric #include <__functional/invoke.h> 1504eeddc0SDimitry Andric #include <__functional/weak_result_type.h> 1606c3fb27SDimitry Andric #include <__type_traits/decay.h> 1706c3fb27SDimitry Andric #include <__type_traits/is_reference_wrapper.h> 1806c3fb27SDimitry Andric #include <__type_traits/is_void.h> 19fe6060f1SDimitry Andric #include <cstddef> 20fe6060f1SDimitry Andric #include <tuple> 21fe6060f1SDimitry Andric 22fe6060f1SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 23fe6060f1SDimitry Andric # pragma GCC system_header 24fe6060f1SDimitry Andric #endif 25fe6060f1SDimitry Andric 26fe6060f1SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD 27fe6060f1SDimitry Andric 2804eeddc0SDimitry Andric template<class _Tp> 2904eeddc0SDimitry Andric struct is_bind_expression : _If< 30bdd1243dSDimitry Andric _IsSame<_Tp, __remove_cvref_t<_Tp> >::value, 3104eeddc0SDimitry Andric false_type, 32bdd1243dSDimitry Andric is_bind_expression<__remove_cvref_t<_Tp> > 3304eeddc0SDimitry Andric > {}; 34fe6060f1SDimitry Andric 3506c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 17 36fe6060f1SDimitry Andric template <class _Tp> 3706c3fb27SDimitry Andric inline constexpr bool is_bind_expression_v = is_bind_expression<_Tp>::value; 38fe6060f1SDimitry Andric #endif 39fe6060f1SDimitry Andric 4004eeddc0SDimitry Andric template<class _Tp> 4104eeddc0SDimitry Andric struct is_placeholder : _If< 42bdd1243dSDimitry Andric _IsSame<_Tp, __remove_cvref_t<_Tp> >::value, 4304eeddc0SDimitry Andric integral_constant<int, 0>, 44bdd1243dSDimitry Andric is_placeholder<__remove_cvref_t<_Tp> > 4504eeddc0SDimitry Andric > {}; 46fe6060f1SDimitry Andric 4706c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 17 48fe6060f1SDimitry Andric template <class _Tp> 4906c3fb27SDimitry Andric inline constexpr int is_placeholder_v = is_placeholder<_Tp>::value; 50fe6060f1SDimitry Andric #endif 51fe6060f1SDimitry Andric 52fe6060f1SDimitry Andric namespace placeholders 53fe6060f1SDimitry Andric { 54fe6060f1SDimitry Andric 55fe6060f1SDimitry Andric template <int _Np> struct __ph {}; 56fe6060f1SDimitry Andric 5706c3fb27SDimitry Andric // C++17 recommends that we implement placeholders as `inline constexpr`, but allows 5806c3fb27SDimitry Andric // implementing them as `extern <implementation-defined>`. Libc++ implements them as 5906c3fb27SDimitry Andric // `extern const` in all standard modes to avoid an ABI break in C++03: making them 6006c3fb27SDimitry Andric // `inline constexpr` requires removing their definition in the shared library to 6106c3fb27SDimitry Andric // avoid ODR violations, which is an ABI break. 6206c3fb27SDimitry Andric // 6306c3fb27SDimitry Andric // In practice, since placeholders are empty, `extern const` is almost impossible 6406c3fb27SDimitry Andric // to distinguish from `inline constexpr` from a usage stand point. 6506c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<1> _1; 6606c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<2> _2; 6706c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<3> _3; 6806c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<4> _4; 6906c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<5> _5; 7006c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<6> _6; 7106c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<7> _7; 7206c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<8> _8; 7306c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<9> _9; 7406c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<10> _10; 75fe6060f1SDimitry Andric 760eae32dcSDimitry Andric } // namespace placeholders 77fe6060f1SDimitry Andric 78fe6060f1SDimitry Andric template<int _Np> 7904eeddc0SDimitry Andric struct is_placeholder<placeholders::__ph<_Np> > 80fe6060f1SDimitry Andric : public integral_constant<int, _Np> {}; 81fe6060f1SDimitry Andric 82fe6060f1SDimitry Andric 83fe6060f1SDimitry Andric #ifndef _LIBCPP_CXX03_LANG 84fe6060f1SDimitry Andric 85fe6060f1SDimitry Andric template <class _Tp, class _Uj> 86*5f757f3fSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 87fe6060f1SDimitry Andric _Tp& 88fe6060f1SDimitry Andric __mu(reference_wrapper<_Tp> __t, _Uj&) 89fe6060f1SDimitry Andric { 90fe6060f1SDimitry Andric return __t.get(); 91fe6060f1SDimitry Andric } 92fe6060f1SDimitry Andric 93fe6060f1SDimitry Andric template <class _Ti, class ..._Uj, size_t ..._Indx> 94*5f757f3fSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 95fe6060f1SDimitry Andric typename __invoke_of<_Ti&, _Uj...>::type 96fe6060f1SDimitry Andric __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) 97fe6060f1SDimitry Andric { 98*5f757f3fSDimitry Andric return __ti(std::forward<_Uj>(std::get<_Indx>(__uj))...); 99fe6060f1SDimitry Andric } 100fe6060f1SDimitry Andric 101*5f757f3fSDimitry Andric template <class _Ti, class ..._Uj, __enable_if_t<is_bind_expression<_Ti>::value, int> = 0> 102*5f757f3fSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 103*5f757f3fSDimitry Andric typename __invoke_of<_Ti&, _Uj...>::type 104fe6060f1SDimitry Andric __mu(_Ti& __ti, tuple<_Uj...>& __uj) 105fe6060f1SDimitry Andric { 106fe6060f1SDimitry Andric typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices; 107*5f757f3fSDimitry Andric return std::__mu_expand(__ti, __uj, __indices()); 108fe6060f1SDimitry Andric } 109fe6060f1SDimitry Andric 110fe6060f1SDimitry Andric template <bool IsPh, class _Ti, class _Uj> 111fe6060f1SDimitry Andric struct __mu_return2 {}; 112fe6060f1SDimitry Andric 113fe6060f1SDimitry Andric template <class _Ti, class _Uj> 114fe6060f1SDimitry Andric struct __mu_return2<true, _Ti, _Uj> 115fe6060f1SDimitry Andric { 116fe6060f1SDimitry Andric typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type; 117fe6060f1SDimitry Andric }; 118fe6060f1SDimitry Andric 119*5f757f3fSDimitry Andric template <class _Ti, class _Uj, __enable_if_t<0 < is_placeholder<_Ti>::value, int> = 0> 120*5f757f3fSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 121fe6060f1SDimitry Andric typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type 122fe6060f1SDimitry Andric __mu(_Ti&, _Uj& __uj) 123fe6060f1SDimitry Andric { 12406c3fb27SDimitry Andric const size_t __indx = is_placeholder<_Ti>::value - 1; 125*5f757f3fSDimitry Andric return std::forward<typename tuple_element<__indx, _Uj>::type>(std::get<__indx>(__uj)); 126fe6060f1SDimitry Andric } 127fe6060f1SDimitry Andric 128*5f757f3fSDimitry Andric template <class _Ti, class _Uj, __enable_if_t<!is_bind_expression<_Ti>::value && 129fe6060f1SDimitry Andric is_placeholder<_Ti>::value == 0 && 130*5f757f3fSDimitry Andric !__is_reference_wrapper<_Ti>::value, int> = 0> 131*5f757f3fSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 132fe6060f1SDimitry Andric _Ti& 133fe6060f1SDimitry Andric __mu(_Ti& __ti, _Uj&) 134fe6060f1SDimitry Andric { 135fe6060f1SDimitry Andric return __ti; 136fe6060f1SDimitry Andric } 137fe6060f1SDimitry Andric 138fe6060f1SDimitry Andric template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh, 139fe6060f1SDimitry Andric class _TupleUj> 140fe6060f1SDimitry Andric struct __mu_return_impl; 141fe6060f1SDimitry Andric 142fe6060f1SDimitry Andric template <bool _Invokable, class _Ti, class ..._Uj> 143fe6060f1SDimitry Andric struct __mu_return_invokable // false 144fe6060f1SDimitry Andric { 145fe6060f1SDimitry Andric typedef __nat type; 146fe6060f1SDimitry Andric }; 147fe6060f1SDimitry Andric 148fe6060f1SDimitry Andric template <class _Ti, class ..._Uj> 149fe6060f1SDimitry Andric struct __mu_return_invokable<true, _Ti, _Uj...> 150fe6060f1SDimitry Andric { 151fe6060f1SDimitry Andric typedef typename __invoke_of<_Ti&, _Uj...>::type type; 152fe6060f1SDimitry Andric }; 153fe6060f1SDimitry Andric 154fe6060f1SDimitry Andric template <class _Ti, class ..._Uj> 155fe6060f1SDimitry Andric struct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...> > 156fe6060f1SDimitry Andric : public __mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...> 157fe6060f1SDimitry Andric { 158fe6060f1SDimitry Andric }; 159fe6060f1SDimitry Andric 160fe6060f1SDimitry Andric template <class _Ti, class _TupleUj> 161fe6060f1SDimitry Andric struct __mu_return_impl<_Ti, false, false, true, _TupleUj> 162fe6060f1SDimitry Andric { 163fe6060f1SDimitry Andric typedef typename tuple_element<is_placeholder<_Ti>::value - 1, 164fe6060f1SDimitry Andric _TupleUj>::type&& type; 165fe6060f1SDimitry Andric }; 166fe6060f1SDimitry Andric 167fe6060f1SDimitry Andric template <class _Ti, class _TupleUj> 168fe6060f1SDimitry Andric struct __mu_return_impl<_Ti, true, false, false, _TupleUj> 169fe6060f1SDimitry Andric { 170fe6060f1SDimitry Andric typedef typename _Ti::type& type; 171fe6060f1SDimitry Andric }; 172fe6060f1SDimitry Andric 173fe6060f1SDimitry Andric template <class _Ti, class _TupleUj> 174fe6060f1SDimitry Andric struct __mu_return_impl<_Ti, false, false, false, _TupleUj> 175fe6060f1SDimitry Andric { 176fe6060f1SDimitry Andric typedef _Ti& type; 177fe6060f1SDimitry Andric }; 178fe6060f1SDimitry Andric 179fe6060f1SDimitry Andric template <class _Ti, class _TupleUj> 180fe6060f1SDimitry Andric struct __mu_return 181fe6060f1SDimitry Andric : public __mu_return_impl<_Ti, 182fe6060f1SDimitry Andric __is_reference_wrapper<_Ti>::value, 183fe6060f1SDimitry Andric is_bind_expression<_Ti>::value, 184fe6060f1SDimitry Andric 0 < is_placeholder<_Ti>::value && 185fe6060f1SDimitry Andric is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value, 186fe6060f1SDimitry Andric _TupleUj> 187fe6060f1SDimitry Andric { 188fe6060f1SDimitry Andric }; 189fe6060f1SDimitry Andric 190fe6060f1SDimitry Andric template <class _Fp, class _BoundArgs, class _TupleUj> 191fe6060f1SDimitry Andric struct __is_valid_bind_return 192fe6060f1SDimitry Andric { 193fe6060f1SDimitry Andric static const bool value = false; 194fe6060f1SDimitry Andric }; 195fe6060f1SDimitry Andric 196fe6060f1SDimitry Andric template <class _Fp, class ..._BoundArgs, class _TupleUj> 197fe6060f1SDimitry Andric struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> 198fe6060f1SDimitry Andric { 199fe6060f1SDimitry Andric static const bool value = __invokable<_Fp, 200fe6060f1SDimitry Andric typename __mu_return<_BoundArgs, _TupleUj>::type...>::value; 201fe6060f1SDimitry Andric }; 202fe6060f1SDimitry Andric 203fe6060f1SDimitry Andric template <class _Fp, class ..._BoundArgs, class _TupleUj> 204fe6060f1SDimitry Andric struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> 205fe6060f1SDimitry Andric { 206fe6060f1SDimitry Andric static const bool value = __invokable<_Fp, 207fe6060f1SDimitry Andric typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value; 208fe6060f1SDimitry Andric }; 209fe6060f1SDimitry Andric 210fe6060f1SDimitry Andric template <class _Fp, class _BoundArgs, class _TupleUj, 211fe6060f1SDimitry Andric bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value> 212fe6060f1SDimitry Andric struct __bind_return; 213fe6060f1SDimitry Andric 214fe6060f1SDimitry Andric template <class _Fp, class ..._BoundArgs, class _TupleUj> 215fe6060f1SDimitry Andric struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> 216fe6060f1SDimitry Andric { 217fe6060f1SDimitry Andric typedef typename __invoke_of 218fe6060f1SDimitry Andric < 219fe6060f1SDimitry Andric _Fp&, 220fe6060f1SDimitry Andric typename __mu_return 221fe6060f1SDimitry Andric < 222fe6060f1SDimitry Andric _BoundArgs, 223fe6060f1SDimitry Andric _TupleUj 224fe6060f1SDimitry Andric >::type... 225fe6060f1SDimitry Andric >::type type; 226fe6060f1SDimitry Andric }; 227fe6060f1SDimitry Andric 228fe6060f1SDimitry Andric template <class _Fp, class ..._BoundArgs, class _TupleUj> 229fe6060f1SDimitry Andric struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> 230fe6060f1SDimitry Andric { 231fe6060f1SDimitry Andric typedef typename __invoke_of 232fe6060f1SDimitry Andric < 233fe6060f1SDimitry Andric _Fp&, 234fe6060f1SDimitry Andric typename __mu_return 235fe6060f1SDimitry Andric < 236fe6060f1SDimitry Andric const _BoundArgs, 237fe6060f1SDimitry Andric _TupleUj 238fe6060f1SDimitry Andric >::type... 239fe6060f1SDimitry Andric >::type type; 240fe6060f1SDimitry Andric }; 241fe6060f1SDimitry Andric 242fe6060f1SDimitry Andric template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args> 243*5f757f3fSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 244fe6060f1SDimitry Andric typename __bind_return<_Fp, _BoundArgs, _Args>::type 245fe6060f1SDimitry Andric __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, 246fe6060f1SDimitry Andric _Args&& __args) 247fe6060f1SDimitry Andric { 248*5f757f3fSDimitry Andric return std::__invoke(__f, std::__mu(std::get<_Indx>(__bound_args), __args)...); 249fe6060f1SDimitry Andric } 250fe6060f1SDimitry Andric 251fe6060f1SDimitry Andric template<class _Fp, class ..._BoundArgs> 25206c3fb27SDimitry Andric class __bind : public __weak_result_type<__decay_t<_Fp> > 253fe6060f1SDimitry Andric { 254fe6060f1SDimitry Andric protected: 25506c3fb27SDimitry Andric using _Fd = __decay_t<_Fp>; 25606c3fb27SDimitry Andric typedef tuple<__decay_t<_BoundArgs>...> _Td; 257fe6060f1SDimitry Andric private: 258fe6060f1SDimitry Andric _Fd __f_; 259fe6060f1SDimitry Andric _Td __bound_args_; 260fe6060f1SDimitry Andric 261fe6060f1SDimitry Andric typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices; 262fe6060f1SDimitry Andric public: 263fe6060f1SDimitry Andric template <class _Gp, class ..._BA, 264*5f757f3fSDimitry Andric __enable_if_t<is_constructible<_Fd, _Gp>::value && !is_same<__libcpp_remove_reference_t<_Gp>, __bind>::value, int> = 0> 265*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 266fe6060f1SDimitry Andric explicit __bind(_Gp&& __f, _BA&& ...__bound_args) 267*5f757f3fSDimitry Andric : __f_(std::forward<_Gp>(__f)), 268*5f757f3fSDimitry Andric __bound_args_(std::forward<_BA>(__bound_args)...) {} 269fe6060f1SDimitry Andric 270fe6060f1SDimitry Andric template <class ..._Args> 271*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 272fe6060f1SDimitry Andric typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type 273fe6060f1SDimitry Andric operator()(_Args&& ...__args) 274fe6060f1SDimitry Andric { 275*5f757f3fSDimitry Andric return std::__apply_functor(__f_, __bound_args_, __indices(), 276*5f757f3fSDimitry Andric tuple<_Args&&...>(std::forward<_Args>(__args)...)); 277fe6060f1SDimitry Andric } 278fe6060f1SDimitry Andric 279fe6060f1SDimitry Andric template <class ..._Args> 280*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 281fe6060f1SDimitry Andric typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type 282fe6060f1SDimitry Andric operator()(_Args&& ...__args) const 283fe6060f1SDimitry Andric { 284*5f757f3fSDimitry Andric return std::__apply_functor(__f_, __bound_args_, __indices(), 285*5f757f3fSDimitry Andric tuple<_Args&&...>(std::forward<_Args>(__args)...)); 286fe6060f1SDimitry Andric } 287fe6060f1SDimitry Andric }; 288fe6060f1SDimitry Andric 289fe6060f1SDimitry Andric template<class _Fp, class ..._BoundArgs> 29004eeddc0SDimitry Andric struct is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {}; 291fe6060f1SDimitry Andric 292fe6060f1SDimitry Andric template<class _Rp, class _Fp, class ..._BoundArgs> 293fe6060f1SDimitry Andric class __bind_r 294fe6060f1SDimitry Andric : public __bind<_Fp, _BoundArgs...> 295fe6060f1SDimitry Andric { 296fe6060f1SDimitry Andric typedef __bind<_Fp, _BoundArgs...> base; 297fe6060f1SDimitry Andric typedef typename base::_Fd _Fd; 298fe6060f1SDimitry Andric typedef typename base::_Td _Td; 299fe6060f1SDimitry Andric public: 300fe6060f1SDimitry Andric typedef _Rp result_type; 301fe6060f1SDimitry Andric 302fe6060f1SDimitry Andric 303fe6060f1SDimitry Andric template <class _Gp, class ..._BA, 304*5f757f3fSDimitry Andric __enable_if_t<is_constructible<_Fd, _Gp>::value && !is_same<__libcpp_remove_reference_t<_Gp>, __bind_r>::value, int> = 0> 305*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 306fe6060f1SDimitry Andric explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args) 307*5f757f3fSDimitry Andric : base(std::forward<_Gp>(__f), 308*5f757f3fSDimitry Andric std::forward<_BA>(__bound_args)...) {} 309fe6060f1SDimitry Andric 310*5f757f3fSDimitry Andric template <class ..._Args, __enable_if_t<is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type, 311*5f757f3fSDimitry Andric result_type>::value || is_void<_Rp>::value, int> = 0> 312*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 313fe6060f1SDimitry Andric result_type 314fe6060f1SDimitry Andric operator()(_Args&& ...__args) 315fe6060f1SDimitry Andric { 316fe6060f1SDimitry Andric typedef __invoke_void_return_wrapper<_Rp> _Invoker; 317*5f757f3fSDimitry Andric return _Invoker::__call(static_cast<base&>(*this), std::forward<_Args>(__args)...); 318fe6060f1SDimitry Andric } 319fe6060f1SDimitry Andric 320*5f757f3fSDimitry Andric template <class ..._Args, __enable_if_t<is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type, 321*5f757f3fSDimitry Andric result_type>::value || is_void<_Rp>::value, int> = 0> 322*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 323fe6060f1SDimitry Andric result_type 324fe6060f1SDimitry Andric operator()(_Args&& ...__args) const 325fe6060f1SDimitry Andric { 326fe6060f1SDimitry Andric typedef __invoke_void_return_wrapper<_Rp> _Invoker; 327*5f757f3fSDimitry Andric return _Invoker::__call(static_cast<base const&>(*this), std::forward<_Args>(__args)...); 328fe6060f1SDimitry Andric } 329fe6060f1SDimitry Andric }; 330fe6060f1SDimitry Andric 331fe6060f1SDimitry Andric template<class _Rp, class _Fp, class ..._BoundArgs> 33204eeddc0SDimitry Andric struct is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; 333fe6060f1SDimitry Andric 334fe6060f1SDimitry Andric template<class _Fp, class ..._BoundArgs> 335*5f757f3fSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 336fe6060f1SDimitry Andric __bind<_Fp, _BoundArgs...> 337fe6060f1SDimitry Andric bind(_Fp&& __f, _BoundArgs&&... __bound_args) 338fe6060f1SDimitry Andric { 339fe6060f1SDimitry Andric typedef __bind<_Fp, _BoundArgs...> type; 340*5f757f3fSDimitry Andric return type(std::forward<_Fp>(__f), std::forward<_BoundArgs>(__bound_args)...); 341fe6060f1SDimitry Andric } 342fe6060f1SDimitry Andric 343fe6060f1SDimitry Andric template<class _Rp, class _Fp, class ..._BoundArgs> 344*5f757f3fSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 345fe6060f1SDimitry Andric __bind_r<_Rp, _Fp, _BoundArgs...> 346fe6060f1SDimitry Andric bind(_Fp&& __f, _BoundArgs&&... __bound_args) 347fe6060f1SDimitry Andric { 348fe6060f1SDimitry Andric typedef __bind_r<_Rp, _Fp, _BoundArgs...> type; 349*5f757f3fSDimitry Andric return type(std::forward<_Fp>(__f), std::forward<_BoundArgs>(__bound_args)...); 350fe6060f1SDimitry Andric } 351fe6060f1SDimitry Andric 352fe6060f1SDimitry Andric #endif // _LIBCPP_CXX03_LANG 353fe6060f1SDimitry Andric 354fe6060f1SDimitry Andric _LIBCPP_END_NAMESPACE_STD 355fe6060f1SDimitry Andric 356fe6060f1SDimitry Andric #endif // _LIBCPP___FUNCTIONAL_BIND_H 357