tag_type.hpp 2.5 KB

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