1 // Copyright David Abrahams, Daniel Wallin 2003. 2 // Distributed under the Boost Software License, Version 1.0. 3 // (See accompanying file LICENSE_1_0.txt or copy at 4 // http://www.boost.org/LICENSE_1_0.txt) 5 6 #ifndef BOOST_PARAMETER_DEDUCED_HPP 7 #define BOOST_PARAMETER_DEDUCED_HPP 8 9 #include <boost/parameter/aux_/use_default.hpp> 10 11 namespace boost { namespace parameter { 12 13 // This metafunction can be used to describe the treatment of particular 14 // named parameters for the purposes of overload elimination with SFINAE, 15 // by placing specializations in the parameters<...> list. 16 // 17 // If a keyword k is specified with deduced<...>, that keyword 18 // will be automatically deduced from the argument list. 19 template <typename Tag> 20 struct deduced 21 { 22 typedef Tag key_type; 23 }; 24 }} 25 26 #include <boost/parameter/config.hpp> 27 28 #if defined(BOOST_PARAMETER_CAN_USE_MP11) 29 #include <boost/mp11/integral.hpp> 30 #else 31 #include <boost/mpl/bool.hpp> 32 #endif 33 34 namespace boost { namespace parameter { namespace aux { 35 36 template <typename T> 37 struct is_deduced_aux 38 #if defined(BOOST_PARAMETER_CAN_USE_MP11) 39 : ::boost::mp11::mp_false 40 #else 41 : ::boost::mpl::false_ 42 #endif 43 { 44 }; 45 46 template <typename Tag> 47 struct is_deduced_aux< ::boost::parameter::deduced<Tag> > 48 #if defined(BOOST_PARAMETER_CAN_USE_MP11) 49 : ::boost::mp11::mp_true 50 #else 51 : ::boost::mpl::true_ 52 #endif 53 { 54 }; 55 56 template <typename T> 57 struct is_deduced0 58 : ::boost::parameter::aux::is_deduced_aux<typename T::key_type>::type 59 { 60 }; 61 }}} // namespace boost::parameter::aux 62 63 #include <boost/parameter/required.hpp> 64 #include <boost/parameter/optional.hpp> 65 66 #if defined(BOOST_PARAMETER_CAN_USE_MP11) 67 #include <boost/mp11/utility.hpp> 68 #else 69 #include <boost/mpl/if.hpp> 70 #endif 71 72 namespace boost { namespace parameter { namespace aux { 73 74 // 75 // tag_type, has_default, and predicate -- 76 // 77 // These metafunctions accept a ParameterSpec and extract the 78 // keyword tag, whether or not a default is supplied for the 79 // parameter, and the predicate that the corresponding actual 80 // argument type is required match. 81 // 82 // a ParameterSpec is a specialization of either keyword<...>, 83 // required<...>, optional<...> 84 // 85 86 template <typename T> 87 #if defined(BOOST_PARAMETER_CAN_USE_MP11) 88 using has_default = ::boost::mp11::mp_if< 89 ::boost::parameter::aux::is_required<T> 90 , ::boost::mp11::mp_false 91 , ::boost::mp11::mp_true 92 >; 93 #else 94 struct has_default 95 : ::boost::mpl::if_< 96 ::boost::parameter::aux::is_required<T> 97 , ::boost::mpl::false_ 98 , ::boost::mpl::true_ 99 >::type 100 { 101 }; 102 #endif 103 104 template <typename T> 105 #if defined(BOOST_PARAMETER_CAN_USE_MP11) 106 using is_deduced = ::boost::mp11::mp_if< 107 ::boost::mp11::mp_if< 108 ::boost::parameter::aux::is_optional<T> 109 , ::boost::mp11::mp_true 110 , ::boost::parameter::aux::is_required<T> 111 > 112 , ::boost::parameter::aux::is_deduced0<T> 113 , ::boost::mp11::mp_false 114 >; 115 #else 116 struct is_deduced 117 : ::boost::mpl::if_< 118 typename ::boost::mpl::if_< 119 ::boost::parameter::aux::is_optional<T> 120 , ::boost::mpl::true_ 121 , ::boost::parameter::aux::is_required<T> 122 >::type 123 , ::boost::parameter::aux::is_deduced0<T> 124 , ::boost::mpl::false_ 125 >::type 126 { 127 }; 128 #endif // BOOST_PARAMETER_CAN_USE_MP11 129 }}} // namespace boost::parameter::aux 130 131 #endif // include guard 132 133