[29] | 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 | # if BOOST_WORKAROUND(BOOST_MSVC, < 1300) |
---|
| 15 | # include <boost/mpl/eval_if.hpp> |
---|
| 16 | # endif |
---|
| 17 | |
---|
| 18 | namespace boost { namespace parameter { |
---|
| 19 | |
---|
| 20 | // A metafunction that, given an argument pack, returns the type of |
---|
| 21 | // the parameter identified by the given keyword. If no such |
---|
| 22 | // parameter has been specified, returns Default |
---|
| 23 | |
---|
| 24 | # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \ |
---|
| 25 | || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) |
---|
| 26 | template <class Parameters, class Keyword, class Default> |
---|
| 27 | struct binding0 |
---|
| 28 | { |
---|
| 29 | typedef typename mpl::apply_wrap3< |
---|
| 30 | typename Parameters::binding,Keyword,Default,mpl::true_ |
---|
| 31 | >::type type; |
---|
| 32 | |
---|
| 33 | BOOST_MPL_ASSERT_NOT(( |
---|
| 34 | mpl::and_< |
---|
| 35 | is_same<Default, void_> |
---|
| 36 | , is_same<type, void_> |
---|
| 37 | > |
---|
| 38 | )); |
---|
| 39 | }; |
---|
| 40 | # endif |
---|
| 41 | |
---|
| 42 | template <class Parameters, class Keyword, class Default = void_> |
---|
| 43 | # if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) |
---|
| 44 | struct binding |
---|
| 45 | # else |
---|
| 46 | struct binding_eti |
---|
| 47 | # endif |
---|
| 48 | { |
---|
| 49 | # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \ |
---|
| 50 | || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) |
---|
| 51 | typedef typename mpl::eval_if< |
---|
| 52 | mpl::is_placeholder<Parameters> |
---|
| 53 | , mpl::identity<int> |
---|
| 54 | , binding0<Parameters,Keyword,Default> |
---|
| 55 | >::type type; |
---|
| 56 | # else |
---|
| 57 | typedef typename mpl::apply_wrap3< |
---|
| 58 | typename Parameters::binding,Keyword,Default,mpl::true_ |
---|
| 59 | >::type type; |
---|
| 60 | |
---|
| 61 | BOOST_MPL_ASSERT_NOT(( |
---|
| 62 | mpl::and_< |
---|
| 63 | is_same<Default, void_> |
---|
| 64 | , is_same<type, void_> |
---|
| 65 | > |
---|
| 66 | )); |
---|
| 67 | # endif |
---|
| 68 | |
---|
| 69 | # if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) |
---|
| 70 | BOOST_MPL_AUX_LAMBDA_SUPPORT(3,binding,(Parameters,Keyword,Default)) |
---|
| 71 | # endif |
---|
| 72 | }; |
---|
| 73 | |
---|
| 74 | # if BOOST_WORKAROUND(BOOST_MSVC, < 1300) |
---|
| 75 | template <class Parameters, class Keyword, class Default = void_> |
---|
| 76 | struct binding |
---|
| 77 | { |
---|
| 78 | typedef typename mpl::eval_if< |
---|
| 79 | is_same<Parameters, int> |
---|
| 80 | , mpl::identity<int> |
---|
| 81 | , binding_eti<Parameters, Keyword, Default> |
---|
| 82 | >::type type; |
---|
| 83 | |
---|
| 84 | BOOST_MPL_AUX_LAMBDA_SUPPORT(3,binding,(Parameters,Keyword,Default)) |
---|
| 85 | }; |
---|
| 86 | # endif |
---|
| 87 | |
---|
| 88 | // A metafunction that, given an argument pack, returns the type of |
---|
| 89 | // the parameter identified by the given keyword. If no such |
---|
| 90 | // parameter has been specified, returns the type returned by invoking |
---|
| 91 | // DefaultFn |
---|
| 92 | template <class Parameters, class Keyword, class DefaultFn> |
---|
| 93 | struct lazy_binding |
---|
| 94 | { |
---|
| 95 | typedef typename mpl::apply_wrap3< |
---|
| 96 | typename Parameters::binding |
---|
| 97 | , Keyword |
---|
| 98 | , typename aux::result_of0<DefaultFn>::type |
---|
| 99 | , mpl::true_ |
---|
| 100 | >::type type; |
---|
| 101 | }; |
---|
| 102 | |
---|
| 103 | |
---|
| 104 | }} // namespace boost::parameter |
---|
| 105 | |
---|
| 106 | #endif // BOOST_PARAMETER_BINDING_DWA200558_HPP |
---|