ossrv_pub/boost_apis/boost/parameter/value_type.hpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright Daniel Wallin 2006. Use, modification and distribution is
       
     2 // subject to the Boost 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 
       
     5 #ifndef BOOST_PARAMETER_VALUE_TYPE_060921_HPP
       
     6 # define BOOST_PARAMETER_VALUE_TYPE_060921_HPP
       
     7 
       
     8 # include <boost/mpl/apply.hpp>
       
     9 # include <boost/mpl/assert.hpp>
       
    10 # include <boost/mpl/and.hpp>
       
    11 # include <boost/parameter/aux_/result_of0.hpp>
       
    12 # include <boost/parameter/aux_/void.hpp>
       
    13 # include <boost/type_traits/is_same.hpp>
       
    14 
       
    15 # if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
       
    16 #  include <boost/mpl/eval_if.hpp>
       
    17 # endif
       
    18 
       
    19 namespace boost { namespace parameter { 
       
    20 
       
    21 // A metafunction that, given an argument pack, returns the type of
       
    22 // the parameter identified by the given keyword.  If no such
       
    23 // parameter has been specified, returns Default
       
    24 
       
    25 # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
       
    26   || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
       
    27 template <class Parameters, class Keyword, class Default>
       
    28 struct value_type0
       
    29 {
       
    30     typedef typename mpl::apply_wrap3<
       
    31         typename Parameters::binding,Keyword,Default,mpl::false_
       
    32     >::type type;
       
    33 
       
    34     BOOST_MPL_ASSERT_NOT((
       
    35         mpl::and_<
       
    36             is_same<Default, void_>
       
    37           , is_same<type, void_>
       
    38         >
       
    39     ));
       
    40 };
       
    41 # endif
       
    42 
       
    43 template <class Parameters, class Keyword, class Default = void_>
       
    44 # if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
       
    45 struct value_type
       
    46 # else
       
    47 struct value_type_eti
       
    48 # endif
       
    49 {
       
    50 # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
       
    51   || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
       
    52     typedef typename mpl::eval_if<
       
    53         mpl::is_placeholder<Parameters>
       
    54       , mpl::identity<int>
       
    55       , value_type0<Parameters,Keyword,Default>
       
    56     >::type type;
       
    57 # else
       
    58     typedef typename mpl::apply_wrap3<
       
    59         typename Parameters::binding,Keyword,Default,mpl::false_
       
    60     >::type type;
       
    61 
       
    62     BOOST_MPL_ASSERT_NOT((
       
    63         mpl::and_<
       
    64             is_same<Default, void_>
       
    65           , is_same<type, void_>
       
    66         >
       
    67     ));
       
    68 # endif
       
    69 
       
    70 # if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
       
    71     BOOST_MPL_AUX_LAMBDA_SUPPORT(3,value_type,(Parameters,Keyword,Default))
       
    72 # endif
       
    73 };
       
    74 
       
    75 # if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
       
    76 template <class Parameters, class Keyword, class Default = void_>
       
    77 struct value_type
       
    78 {
       
    79     typedef typename mpl::eval_if<
       
    80         is_same<Parameters, int>
       
    81       , mpl::identity<int>
       
    82       , value_type_eti<Parameters, Keyword, Default>
       
    83     >::type type;
       
    84 
       
    85     BOOST_MPL_AUX_LAMBDA_SUPPORT(3,value_type,(Parameters,Keyword,Default))
       
    86 };
       
    87 # endif
       
    88 
       
    89 // A metafunction that, given an argument pack, returns the type of
       
    90 // the parameter identified by the given keyword.  If no such
       
    91 // parameter has been specified, returns the type returned by invoking
       
    92 // DefaultFn
       
    93 template <class Parameters, class Keyword, class DefaultFn>
       
    94 struct lazy_value_type
       
    95 {
       
    96   typedef typename mpl::apply_wrap3<
       
    97       typename Parameters::binding
       
    98     , Keyword
       
    99     , typename aux::result_of0<DefaultFn>::type
       
   100     , mpl::false_
       
   101   >::type type;
       
   102 };
       
   103 
       
   104 
       
   105 }} // namespace boost::parameter
       
   106 
       
   107 #endif // BOOST_PARAMETER_VALUE_TYPE_060921_HPP
       
   108