optional.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_OPTIONAL_HPP
  6. #define BOOST_PARAMETER_OPTIONAL_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. // - The actual argument type matched by every keyword tag
  15. // associated with a predicate must satisfy that predicate
  16. //
  17. // - If a keyword k is specified without an optional<...> or
  18. // required<...> wrapper, it is treated as though
  19. // optional<k> were specified.
  20. template <
  21. typename Tag
  22. , typename Predicate = ::boost::parameter::aux::use_default
  23. >
  24. struct optional
  25. {
  26. typedef Tag key_type;
  27. typedef Predicate predicate;
  28. };
  29. }}
  30. #include <boost/parameter/config.hpp>
  31. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  32. #include <boost/mp11/integral.hpp>
  33. #else
  34. #include <boost/mpl/bool.hpp>
  35. #endif
  36. namespace boost { namespace parameter { namespace aux {
  37. template <typename T>
  38. struct is_optional
  39. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  40. : ::boost::mp11::mp_false
  41. #else
  42. : ::boost::mpl::false_
  43. #endif
  44. {
  45. };
  46. template <typename Tag, typename Predicate>
  47. struct is_optional< ::boost::parameter::optional<Tag,Predicate> >
  48. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  49. : ::boost::mp11::mp_true
  50. #else
  51. : ::boost::mpl::true_
  52. #endif
  53. {
  54. };
  55. }}} // namespace boost::parameter::aux
  56. #endif // include guard