xref: /freebsd-src/contrib/llvm-project/libcxx/include/__functional/bind.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
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>
16*0fca6ea1SDimitry Andric #include <__fwd/functional.h>
1706c3fb27SDimitry Andric #include <__type_traits/decay.h>
1806c3fb27SDimitry Andric #include <__type_traits/is_reference_wrapper.h>
1906c3fb27SDimitry Andric #include <__type_traits/is_void.h>
20fe6060f1SDimitry Andric #include <cstddef>
21fe6060f1SDimitry Andric #include <tuple>
22fe6060f1SDimitry Andric 
23fe6060f1SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24fe6060f1SDimitry Andric #  pragma GCC system_header
25fe6060f1SDimitry Andric #endif
26fe6060f1SDimitry Andric 
27fe6060f1SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
28fe6060f1SDimitry Andric 
2904eeddc0SDimitry Andric template <class _Tp>
30cb14a3feSDimitry Andric struct is_bind_expression
31cb14a3feSDimitry Andric     : _If< _IsSame<_Tp, __remove_cvref_t<_Tp> >::value, false_type, is_bind_expression<__remove_cvref_t<_Tp> > > {};
32fe6060f1SDimitry Andric 
3306c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 17
34fe6060f1SDimitry Andric template <class _Tp>
3506c3fb27SDimitry Andric inline constexpr bool is_bind_expression_v = is_bind_expression<_Tp>::value;
36fe6060f1SDimitry Andric #endif
37fe6060f1SDimitry Andric 
3804eeddc0SDimitry Andric template <class _Tp>
39cb14a3feSDimitry Andric struct is_placeholder
40cb14a3feSDimitry Andric     : _If< _IsSame<_Tp, __remove_cvref_t<_Tp> >::value,
4104eeddc0SDimitry Andric            integral_constant<int, 0>,
42cb14a3feSDimitry Andric            is_placeholder<__remove_cvref_t<_Tp> > > {};
43fe6060f1SDimitry Andric 
4406c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 17
45fe6060f1SDimitry Andric template <class _Tp>
4606c3fb27SDimitry Andric inline constexpr int is_placeholder_v = is_placeholder<_Tp>::value;
47fe6060f1SDimitry Andric #endif
48fe6060f1SDimitry Andric 
49cb14a3feSDimitry Andric namespace placeholders {
50fe6060f1SDimitry Andric 
51cb14a3feSDimitry Andric template <int _Np>
52cb14a3feSDimitry Andric struct __ph {};
53fe6060f1SDimitry Andric 
5406c3fb27SDimitry Andric // C++17 recommends that we implement placeholders as `inline constexpr`, but allows
5506c3fb27SDimitry Andric // implementing them as `extern <implementation-defined>`. Libc++ implements them as
5606c3fb27SDimitry Andric // `extern const` in all standard modes to avoid an ABI break in C++03: making them
5706c3fb27SDimitry Andric // `inline constexpr` requires removing their definition in the shared library to
5806c3fb27SDimitry Andric // avoid ODR violations, which is an ABI break.
5906c3fb27SDimitry Andric //
6006c3fb27SDimitry Andric // In practice, since placeholders are empty, `extern const` is almost impossible
6106c3fb27SDimitry Andric // to distinguish from `inline constexpr` from a usage stand point.
6206c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<1> _1;
6306c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<2> _2;
6406c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<3> _3;
6506c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<4> _4;
6606c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<5> _5;
6706c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<6> _6;
6806c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<7> _7;
6906c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<8> _8;
7006c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<9> _9;
7106c3fb27SDimitry Andric _LIBCPP_EXPORTED_FROM_ABI extern const __ph<10> _10;
72fe6060f1SDimitry Andric 
730eae32dcSDimitry Andric } // namespace placeholders
74fe6060f1SDimitry Andric 
75fe6060f1SDimitry Andric template <int _Np>
76cb14a3feSDimitry Andric struct is_placeholder<placeholders::__ph<_Np> > : public integral_constant<int, _Np> {};
77fe6060f1SDimitry Andric 
78fe6060f1SDimitry Andric #ifndef _LIBCPP_CXX03_LANG
79fe6060f1SDimitry Andric 
80fe6060f1SDimitry Andric template <class _Tp, class _Uj>
81cb14a3feSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __mu(reference_wrapper<_Tp> __t, _Uj&) {
82fe6060f1SDimitry Andric   return __t.get();
83fe6060f1SDimitry Andric }
84fe6060f1SDimitry Andric 
85fe6060f1SDimitry Andric template <class _Ti, class... _Uj, size_t... _Indx>
86cb14a3feSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __invoke_of<_Ti&, _Uj...>::type
87cb14a3feSDimitry Andric __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) {
885f757f3fSDimitry Andric   return __ti(std::forward<_Uj>(std::get<_Indx>(__uj))...);
89fe6060f1SDimitry Andric }
90fe6060f1SDimitry Andric 
915f757f3fSDimitry Andric template <class _Ti, class... _Uj, __enable_if_t<is_bind_expression<_Ti>::value, int> = 0>
92cb14a3feSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __invoke_of<_Ti&, _Uj...>::type
93cb14a3feSDimitry Andric __mu(_Ti& __ti, tuple<_Uj...>& __uj) {
94fe6060f1SDimitry Andric   typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
955f757f3fSDimitry Andric   return std::__mu_expand(__ti, __uj, __indices());
96fe6060f1SDimitry Andric }
97fe6060f1SDimitry Andric 
98*0fca6ea1SDimitry Andric template <bool _IsPh, class _Ti, class _Uj>
99fe6060f1SDimitry Andric struct __mu_return2 {};
100fe6060f1SDimitry Andric 
101fe6060f1SDimitry Andric template <class _Ti, class _Uj>
102cb14a3feSDimitry Andric struct __mu_return2<true, _Ti, _Uj> {
103fe6060f1SDimitry Andric   typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
104fe6060f1SDimitry Andric };
105fe6060f1SDimitry Andric 
1065f757f3fSDimitry Andric template <class _Ti, class _Uj, __enable_if_t<0 < is_placeholder<_Ti>::value, int> = 0>
1075f757f3fSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
108fe6060f1SDimitry Andric typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
109cb14a3feSDimitry Andric __mu(_Ti&, _Uj& __uj) {
11006c3fb27SDimitry Andric   const size_t __indx = is_placeholder<_Ti>::value - 1;
1115f757f3fSDimitry Andric   return std::forward<typename tuple_element<__indx, _Uj>::type>(std::get<__indx>(__uj));
112fe6060f1SDimitry Andric }
113fe6060f1SDimitry Andric 
114cb14a3feSDimitry Andric template <class _Ti,
115cb14a3feSDimitry Andric           class _Uj,
116cb14a3feSDimitry Andric           __enable_if_t<!is_bind_expression<_Ti>::value && is_placeholder<_Ti>::value == 0 &&
117cb14a3feSDimitry Andric                             !__is_reference_wrapper<_Ti>::value,
118cb14a3feSDimitry Andric                         int> = 0>
119cb14a3feSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ti& __mu(_Ti& __ti, _Uj&) {
120fe6060f1SDimitry Andric   return __ti;
121fe6060f1SDimitry Andric }
122fe6060f1SDimitry Andric 
123*0fca6ea1SDimitry Andric template <class _Ti, bool _IsReferenceWrapper, bool _IsBindEx, bool _IsPh, class _TupleUj>
124fe6060f1SDimitry Andric struct __mu_return_impl;
125fe6060f1SDimitry Andric 
126fe6060f1SDimitry Andric template <bool _Invokable, class _Ti, class... _Uj>
127fe6060f1SDimitry Andric struct __mu_return_invokable // false
128fe6060f1SDimitry Andric {
129fe6060f1SDimitry Andric   typedef __nat type;
130fe6060f1SDimitry Andric };
131fe6060f1SDimitry Andric 
132fe6060f1SDimitry Andric template <class _Ti, class... _Uj>
133cb14a3feSDimitry Andric struct __mu_return_invokable<true, _Ti, _Uj...> {
134fe6060f1SDimitry Andric   typedef typename __invoke_of<_Ti&, _Uj...>::type type;
135fe6060f1SDimitry Andric };
136fe6060f1SDimitry Andric 
137fe6060f1SDimitry Andric template <class _Ti, class... _Uj>
138fe6060f1SDimitry Andric struct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...> >
139cb14a3feSDimitry Andric     : public __mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...> {};
140cb14a3feSDimitry Andric 
141cb14a3feSDimitry Andric template <class _Ti, class _TupleUj>
142cb14a3feSDimitry Andric struct __mu_return_impl<_Ti, false, false, true, _TupleUj> {
143cb14a3feSDimitry Andric   typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _TupleUj>::type&& type;
144fe6060f1SDimitry Andric };
145fe6060f1SDimitry Andric 
146fe6060f1SDimitry Andric template <class _Ti, class _TupleUj>
147cb14a3feSDimitry Andric struct __mu_return_impl<_Ti, true, false, false, _TupleUj> {
148fe6060f1SDimitry Andric   typedef typename _Ti::type& type;
149fe6060f1SDimitry Andric };
150fe6060f1SDimitry Andric 
151fe6060f1SDimitry Andric template <class _Ti, class _TupleUj>
152cb14a3feSDimitry Andric struct __mu_return_impl<_Ti, false, false, false, _TupleUj> {
153fe6060f1SDimitry Andric   typedef _Ti& type;
154fe6060f1SDimitry Andric };
155fe6060f1SDimitry Andric 
156fe6060f1SDimitry Andric template <class _Ti, class _TupleUj>
157fe6060f1SDimitry Andric struct __mu_return
158cb14a3feSDimitry Andric     : public __mu_return_impl<
159cb14a3feSDimitry Andric           _Ti,
160fe6060f1SDimitry Andric           __is_reference_wrapper<_Ti>::value,
161fe6060f1SDimitry Andric           is_bind_expression<_Ti>::value,
162cb14a3feSDimitry Andric           0 < is_placeholder<_Ti>::value && is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value,
163cb14a3feSDimitry Andric           _TupleUj> {};
164fe6060f1SDimitry Andric 
165fe6060f1SDimitry Andric template <class _Fp, class _BoundArgs, class _TupleUj>
166cb14a3feSDimitry Andric struct __is_valid_bind_return {
167fe6060f1SDimitry Andric   static const bool value = false;
168fe6060f1SDimitry Andric };
169fe6060f1SDimitry Andric 
170fe6060f1SDimitry Andric template <class _Fp, class... _BoundArgs, class _TupleUj>
171cb14a3feSDimitry Andric struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> {
172cb14a3feSDimitry Andric   static const bool value = __invokable<_Fp, typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
173fe6060f1SDimitry Andric };
174fe6060f1SDimitry Andric 
175fe6060f1SDimitry Andric template <class _Fp, class... _BoundArgs, class _TupleUj>
176cb14a3feSDimitry Andric struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> {
177cb14a3feSDimitry Andric   static const bool value = __invokable<_Fp, typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
178fe6060f1SDimitry Andric };
179fe6060f1SDimitry Andric 
180cb14a3feSDimitry Andric template <class _Fp, class _BoundArgs, class _TupleUj, bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
181fe6060f1SDimitry Andric struct __bind_return;
182fe6060f1SDimitry Andric 
183fe6060f1SDimitry Andric template <class _Fp, class... _BoundArgs, class _TupleUj>
184cb14a3feSDimitry Andric struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> {
185cb14a3feSDimitry Andric   typedef typename __invoke_of< _Fp&, typename __mu_return< _BoundArgs, _TupleUj >::type... >::type type;
186fe6060f1SDimitry Andric };
187fe6060f1SDimitry Andric 
188fe6060f1SDimitry Andric template <class _Fp, class... _BoundArgs, class _TupleUj>
189cb14a3feSDimitry Andric struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> {
190cb14a3feSDimitry Andric   typedef typename __invoke_of< _Fp&, typename __mu_return< const _BoundArgs, _TupleUj >::type... >::type type;
191fe6060f1SDimitry Andric };
192fe6060f1SDimitry Andric 
193fe6060f1SDimitry Andric template <class _Fp, class _BoundArgs, size_t... _Indx, class _Args>
194cb14a3feSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __bind_return<_Fp, _BoundArgs, _Args>::type
195cb14a3feSDimitry Andric __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, _Args&& __args) {
1965f757f3fSDimitry Andric   return std::__invoke(__f, std::__mu(std::get<_Indx>(__bound_args), __args)...);
197fe6060f1SDimitry Andric }
198fe6060f1SDimitry Andric 
199fe6060f1SDimitry Andric template <class _Fp, class... _BoundArgs>
200cb14a3feSDimitry Andric class __bind : public __weak_result_type<__decay_t<_Fp> > {
201fe6060f1SDimitry Andric protected:
20206c3fb27SDimitry Andric   using _Fd = __decay_t<_Fp>;
20306c3fb27SDimitry Andric   typedef tuple<__decay_t<_BoundArgs>...> _Td;
204cb14a3feSDimitry Andric 
205fe6060f1SDimitry Andric private:
206fe6060f1SDimitry Andric   _Fd __f_;
207fe6060f1SDimitry Andric   _Td __bound_args_;
208fe6060f1SDimitry Andric 
209fe6060f1SDimitry Andric   typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
210cb14a3feSDimitry Andric 
211fe6060f1SDimitry Andric public:
212cb14a3feSDimitry Andric   template <
213cb14a3feSDimitry Andric       class _Gp,
214cb14a3feSDimitry Andric       class... _BA,
215cb14a3feSDimitry Andric       __enable_if_t<is_constructible<_Fd, _Gp>::value && !is_same<__libcpp_remove_reference_t<_Gp>, __bind>::value,
216cb14a3feSDimitry Andric                     int> = 0>
217cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bind(_Gp&& __f, _BA&&... __bound_args)
218cb14a3feSDimitry Andric       : __f_(std::forward<_Gp>(__f)), __bound_args_(std::forward<_BA>(__bound_args)...) {}
219fe6060f1SDimitry Andric 
220fe6060f1SDimitry Andric   template <class... _Args>
221cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
222cb14a3feSDimitry Andric   operator()(_Args&&... __args) {
223cb14a3feSDimitry Andric     return std::__apply_functor(__f_, __bound_args_, __indices(), tuple<_Args&&...>(std::forward<_Args>(__args)...));
224fe6060f1SDimitry Andric   }
225fe6060f1SDimitry Andric 
226fe6060f1SDimitry Andric   template <class... _Args>
2275f757f3fSDimitry Andric   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
228fe6060f1SDimitry Andric   typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
229cb14a3feSDimitry Andric   operator()(_Args&&... __args) const {
230cb14a3feSDimitry Andric     return std::__apply_functor(__f_, __bound_args_, __indices(), tuple<_Args&&...>(std::forward<_Args>(__args)...));
231fe6060f1SDimitry Andric   }
232fe6060f1SDimitry Andric };
233fe6060f1SDimitry Andric 
234fe6060f1SDimitry Andric template <class _Fp, class... _BoundArgs>
23504eeddc0SDimitry Andric struct is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
236fe6060f1SDimitry Andric 
237fe6060f1SDimitry Andric template <class _Rp, class _Fp, class... _BoundArgs>
238cb14a3feSDimitry Andric class __bind_r : public __bind<_Fp, _BoundArgs...> {
239fe6060f1SDimitry Andric   typedef __bind<_Fp, _BoundArgs...> base;
240fe6060f1SDimitry Andric   typedef typename base::_Fd _Fd;
241fe6060f1SDimitry Andric   typedef typename base::_Td _Td;
242cb14a3feSDimitry Andric 
243fe6060f1SDimitry Andric public:
244fe6060f1SDimitry Andric   typedef _Rp result_type;
245fe6060f1SDimitry Andric 
246cb14a3feSDimitry Andric   template <
247cb14a3feSDimitry Andric       class _Gp,
248cb14a3feSDimitry Andric       class... _BA,
249cb14a3feSDimitry Andric       __enable_if_t<is_constructible<_Fd, _Gp>::value && !is_same<__libcpp_remove_reference_t<_Gp>, __bind_r>::value,
250cb14a3feSDimitry Andric                     int> = 0>
251cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bind_r(_Gp&& __f, _BA&&... __bound_args)
252cb14a3feSDimitry Andric       : base(std::forward<_Gp>(__f), std::forward<_BA>(__bound_args)...) {}
253fe6060f1SDimitry Andric 
254cb14a3feSDimitry Andric   template <
255cb14a3feSDimitry Andric       class... _Args,
256cb14a3feSDimitry Andric       __enable_if_t<is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type, result_type>::value ||
257cb14a3feSDimitry Andric                         is_void<_Rp>::value,
258cb14a3feSDimitry Andric                     int> = 0>
259cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 result_type operator()(_Args&&... __args) {
260fe6060f1SDimitry Andric     typedef __invoke_void_return_wrapper<_Rp> _Invoker;
2615f757f3fSDimitry Andric     return _Invoker::__call(static_cast<base&>(*this), std::forward<_Args>(__args)...);
262fe6060f1SDimitry Andric   }
263fe6060f1SDimitry Andric 
264cb14a3feSDimitry Andric   template <class... _Args,
265cb14a3feSDimitry Andric             __enable_if_t<is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
266cb14a3feSDimitry Andric                                          result_type>::value ||
267cb14a3feSDimitry Andric                               is_void<_Rp>::value,
268cb14a3feSDimitry Andric                           int> = 0>
269cb14a3feSDimitry Andric   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 result_type operator()(_Args&&... __args) const {
270fe6060f1SDimitry Andric     typedef __invoke_void_return_wrapper<_Rp> _Invoker;
2715f757f3fSDimitry Andric     return _Invoker::__call(static_cast<base const&>(*this), std::forward<_Args>(__args)...);
272fe6060f1SDimitry Andric   }
273fe6060f1SDimitry Andric };
274fe6060f1SDimitry Andric 
275fe6060f1SDimitry Andric template <class _Rp, class _Fp, class... _BoundArgs>
27604eeddc0SDimitry Andric struct is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
277fe6060f1SDimitry Andric 
278fe6060f1SDimitry Andric template <class _Fp, class... _BoundArgs>
279cb14a3feSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bind<_Fp, _BoundArgs...>
280cb14a3feSDimitry Andric bind(_Fp&& __f, _BoundArgs&&... __bound_args) {
281fe6060f1SDimitry Andric   typedef __bind<_Fp, _BoundArgs...> type;
2825f757f3fSDimitry Andric   return type(std::forward<_Fp>(__f), std::forward<_BoundArgs>(__bound_args)...);
283fe6060f1SDimitry Andric }
284fe6060f1SDimitry Andric 
285fe6060f1SDimitry Andric template <class _Rp, class _Fp, class... _BoundArgs>
286cb14a3feSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bind_r<_Rp, _Fp, _BoundArgs...>
287cb14a3feSDimitry Andric bind(_Fp&& __f, _BoundArgs&&... __bound_args) {
288fe6060f1SDimitry Andric   typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
2895f757f3fSDimitry Andric   return type(std::forward<_Fp>(__f), std::forward<_BoundArgs>(__bound_args)...);
290fe6060f1SDimitry Andric }
291fe6060f1SDimitry Andric 
292fe6060f1SDimitry Andric #endif // _LIBCPP_CXX03_LANG
293fe6060f1SDimitry Andric 
294fe6060f1SDimitry Andric _LIBCPP_END_NAMESPACE_STD
295fe6060f1SDimitry Andric 
296fe6060f1SDimitry Andric #endif // _LIBCPP___FUNCTIONAL_BIND_H
297