predicate.hpp 2.5 KB

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