required.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_REQUIRED_HPP
  6. #define BOOST_PARAMETER_REQUIRED_HPP
  7. #include <boost/parameter/aux_/use_default.hpp>
  8. namespace boost { namespace parameter {
  9. // This metafunction can be used to describe the treatment of particular
  10. // named parameters for the purposes of overload elimination with SFINAE,
  11. // by placing specializations in the parameters<...> list. In order for
  12. // a treated function to participate in overload resolution:
  13. //
  14. // - all keyword tags wrapped in required<...> must have a matching
  15. // actual argument
  16. //
  17. // - The actual argument type matched by every keyword tag
  18. // associated with a predicate must satisfy that predicate
  19. template <
  20. typename Tag
  21. , typename Predicate = ::boost::parameter::aux::use_default
  22. >
  23. struct required
  24. {
  25. typedef Tag key_type;
  26. typedef Predicate predicate;
  27. };
  28. }}
  29. #include <boost/parameter/config.hpp>
  30. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  31. #include <boost/mp11/integral.hpp>
  32. #else
  33. #include <boost/mpl/bool.hpp>
  34. #endif
  35. namespace boost { namespace parameter { namespace aux {
  36. template <typename T>
  37. struct is_required
  38. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  39. : ::boost::mp11::mp_false
  40. #else
  41. : ::boost::mpl::false_
  42. #endif
  43. {
  44. };
  45. template <typename Tag, typename Predicate>
  46. struct is_required< ::boost::parameter::required<Tag,Predicate> >
  47. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  48. : ::boost::mp11::mp_true
  49. #else
  50. : ::boost::mpl::true_
  51. #endif
  52. {
  53. };
  54. }}} // namespace boost::parameter::aux
  55. #endif // include guard