]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/parameter/include/boost/parameter/binding.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / parameter / include / boost / parameter / binding.hpp
1 // Copyright David Abrahams 2005. Distributed under the Boost
2 // Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4 #ifndef BOOST_PARAMETER_BINDING_DWA200558_HPP
5 # define BOOST_PARAMETER_BINDING_DWA200558_HPP
6
7 # include <boost/mpl/apply.hpp>
8 # include <boost/mpl/assert.hpp>
9 # include <boost/mpl/and.hpp>
10 # include <boost/parameter/aux_/result_of0.hpp>
11 # include <boost/parameter/aux_/void.hpp>
12 # include <boost/type_traits/is_same.hpp>
13
14 namespace boost { namespace parameter {
15
16 // A metafunction that, given an argument pack, returns the type of
17 // the parameter identified by the given keyword. If no such
18 // parameter has been specified, returns Default
19
20 # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
21 template <class Parameters, class Keyword, class Default>
22 struct binding0
23 {
24 typedef typename mpl::apply_wrap3<
25 typename Parameters::binding,Keyword,Default,mpl::true_
26 >::type type;
27
28 BOOST_MPL_ASSERT_NOT((
29 mpl::and_<
30 is_same<Default, void_>
31 , is_same<type, void_>
32 >
33 ));
34 };
35 # endif
36
37 template <class Parameters, class Keyword, class Default = void_>
38 struct binding
39 {
40 # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
41 typedef typename mpl::eval_if<
42 mpl::is_placeholder<Parameters>
43 , mpl::identity<int>
44 , binding0<Parameters,Keyword,Default>
45 >::type type;
46 # else
47 typedef typename mpl::apply_wrap3<
48 typename Parameters::binding,Keyword,Default,mpl::true_
49 >::type type;
50
51 BOOST_MPL_ASSERT_NOT((
52 mpl::and_<
53 is_same<Default, void_>
54 , is_same<type, void_>
55 >
56 ));
57 # endif
58
59 BOOST_MPL_AUX_LAMBDA_SUPPORT(3,binding,(Parameters,Keyword,Default))
60 };
61
62 // A metafunction that, given an argument pack, returns the type of
63 // the parameter identified by the given keyword. If no such
64 // parameter has been specified, returns the type returned by invoking
65 // DefaultFn
66 template <class Parameters, class Keyword, class DefaultFn>
67 struct lazy_binding
68 {
69 typedef typename mpl::apply_wrap3<
70 typename Parameters::binding
71 , Keyword
72 , typename aux::result_of0<DefaultFn>::type
73 , mpl::true_
74 >::type type;
75 };
76
77
78 }} // namespace boost::parameter
79
80 #endif // BOOST_PARAMETER_BINDING_DWA200558_HPP