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_AUX_PACK_PREDICATE_HPP 7 #define BOOST_PARAMETER_AUX_PACK_PREDICATE_HPP 8 9 namespace boost { namespace parameter { namespace aux { 10 11 // helper for get_predicate<...>, below 12 template <typename T> 13 struct get_predicate_or_default 14 { 15 typedef T type; 16 }; 17 18 // helper for predicate<...>, below 19 template <typename T> 20 struct get_predicate 21 : ::boost::parameter::aux 22 ::get_predicate_or_default<typename T::predicate> 23 { 24 }; 25 }}} // namespace boost::parameter::aux 26 27 #include <boost/parameter/aux_/use_default.hpp> 28 #include <boost/parameter/aux_/always_true_predicate.hpp> 29 30 namespace boost { namespace parameter { namespace aux { 31 32 template <> 33 struct get_predicate_or_default< ::boost::parameter::aux::use_default> 34 { 35 typedef ::boost::parameter::aux::always_true_predicate type; 36 }; 37 }}} // namespace boost::parameter::aux 38 39 #include <boost/parameter/required.hpp> 40 #include <boost/parameter/optional.hpp> 41 #include <boost/parameter/config.hpp> 42 43 #if defined(BOOST_PARAMETER_CAN_USE_MP11) 44 #include <boost/mp11/integral.hpp> 45 #include <boost/mp11/utility.hpp> 46 #else 47 #include <boost/mpl/bool.hpp> 48 #include <boost/mpl/if.hpp> 49 #include <boost/mpl/eval_if.hpp> 50 #include <boost/mpl/identity.hpp> 51 #endif 52 53 namespace boost { namespace parameter { namespace aux { 54 55 template <typename T> 56 #if defined(BOOST_PARAMETER_CAN_USE_MP11) 57 using predicate = ::boost::mp11::mp_if< 58 ::boost::mp11::mp_if< 59 ::boost::parameter::aux::is_optional<T> 60 , ::boost::mp11::mp_true 61 , ::boost::parameter::aux::is_required<T> 62 > 63 , ::boost::parameter::aux::get_predicate<T> 64 , ::boost::mp11::mp_identity< 65 ::boost::parameter::aux::always_true_predicate 66 > 67 >; 68 #else 69 struct predicate 70 : ::boost::mpl::eval_if< 71 typename ::boost::mpl::if_< 72 ::boost::parameter::aux::is_optional<T> 73 , ::boost::mpl::true_ 74 , ::boost::parameter::aux::is_required<T> 75 >::type 76 , ::boost::parameter::aux::get_predicate<T> 77 , ::boost::mpl::identity< 78 ::boost::parameter::aux::always_true_predicate 79 > 80 > 81 { 82 }; 83 #endif // BOOST_PARAMETER_CAN_USE_MP11 84 }}} // namespace boost::parameter::aux 85 86 #endif // include guard 87 88