]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/phoenix/include/boost/phoenix/bind/bind_function.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / phoenix / include / boost / phoenix / bind / bind_function.hpp
1 /*=============================================================================
2 Copyright (c) 2016 Kohei Takahashi
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7
8 #ifndef PHOENIX_BIND_BIND_FUNCTION_HPP
9 #define PHOENIX_BIND_BIND_FUNCTION_HPP
10
11 #include <boost/phoenix/core/limits.hpp>
12
13 #if defined(BOOST_PHOENIX_NO_VARIADIC_BIND)
14 # include <boost/phoenix/bind/detail/cpp03/bind_function.hpp>
15 #else
16
17 #include <boost/phoenix/core/expression.hpp>
18 #include <boost/phoenix/core/detail/function_eval.hpp>
19
20 namespace boost { namespace phoenix
21 {
22 namespace detail
23 {
24 template <typename RT, typename FP>
25 struct function_ptr
26 {
27 typedef RT result_type;
28
29 function_ptr(FP fp_)
30 : fp(fp_) {}
31
32 template <typename... A>
33 result_type operator()(A&... a) const
34 {
35 return fp(a...);
36 }
37
38 bool operator==(function_ptr const& rhs) const
39 {
40 return fp == rhs.fp;
41 }
42
43 template <typename RhsRT, typename RhsFP>
44 bool operator==(function_ptr<RhsRT, RhsFP> const& /*rhs*/) const
45 {
46 return false;
47 }
48
49 FP fp;
50 };
51 } // namespace boost::phoenix::detail
52
53 template <typename RT, typename... T, typename... A>
54 inline typename detail::expression::function_eval<
55 detail::function_ptr<RT, RT (*)(T...)>
56 , A...
57 >::type const
58 bind(RT (*f)(T...), A const&... a)
59 {
60 typedef detail::function_ptr<RT, RT (*)(T...)> fp_type;
61 return detail::expression::function_eval<fp_type, A...>::make(fp_type(f), a...);
62 }
63 }} // namespace boost::phoenix
64
65 #endif
66 #endif