is_tagged_argument.hpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // Copyright Daniel Wallin, David Abrahams 2005.
  2. // Copyright Cromwell D. Enage 2017.
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_PARAMETER_IS_TAGGED_ARGUMENT_HPP
  7. #define BOOST_PARAMETER_IS_TAGGED_ARGUMENT_HPP
  8. namespace boost { namespace parameter { namespace aux {
  9. struct tagged_argument_base
  10. {
  11. };
  12. }}} // namespace boost::parameter::aux
  13. #include <boost/parameter/config.hpp>
  14. #include <boost/mpl/bool.hpp>
  15. #include <boost/mpl/if.hpp>
  16. #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) || \
  17. (0 < BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY)
  18. #include <boost/type_traits/is_base_of.hpp>
  19. #include <boost/type_traits/remove_const.hpp>
  20. #include <boost/type_traits/remove_reference.hpp>
  21. namespace boost { namespace parameter { namespace aux {
  22. // This metafunction identifies tagged_argument specializations
  23. // and their derived classes.
  24. template <typename T>
  25. struct is_tagged_argument
  26. : ::boost::mpl::if_<
  27. // Cannot use is_convertible<> to check if T is derived from
  28. // tagged_argument_base. -- Cromwell D. Enage
  29. ::boost::is_base_of<
  30. ::boost::parameter::aux::tagged_argument_base
  31. , typename ::boost::remove_const<
  32. typename ::boost::remove_reference<T>::type
  33. >::type
  34. >
  35. , ::boost::mpl::true_
  36. , ::boost::mpl::false_
  37. >::type
  38. {
  39. };
  40. }}} // namespace boost::parameter::aux
  41. #else // no perfect forwarding support and no exponential overloads
  42. #include <boost/type_traits/is_convertible.hpp>
  43. #include <boost/type_traits/is_lvalue_reference.hpp>
  44. namespace boost { namespace parameter { namespace aux {
  45. template <typename T>
  46. struct is_tagged_argument_aux
  47. : ::boost::is_convertible<
  48. T*
  49. , ::boost::parameter::aux::tagged_argument_base const*
  50. >
  51. {
  52. };
  53. // This metafunction identifies tagged_argument specializations
  54. // and their derived classes.
  55. template <typename T>
  56. struct is_tagged_argument
  57. : ::boost::mpl::if_<
  58. ::boost::is_lvalue_reference<T>
  59. , ::boost::mpl::false_
  60. , ::boost::parameter::aux::is_tagged_argument_aux<T>
  61. >::type
  62. {
  63. };
  64. }}} // namespace boost::parameter::aux
  65. #endif // perfect forwarding support, or exponential overloads
  66. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  67. #include <type_traits>
  68. namespace boost { namespace parameter { namespace aux {
  69. template <typename T>
  70. using is_tagged_argument_mp11 = ::std::is_base_of<
  71. ::boost::parameter::aux::tagged_argument_base
  72. , typename ::std::remove_const<
  73. typename ::std::remove_reference<T>::type
  74. >::type
  75. >;
  76. }}} // namespace boost::parameter::aux
  77. #endif // BOOST_PARAMETER_CAN_USE_MP11
  78. #endif // include guard