template_keyword.hpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Copyright Daniel Wallin 2006.
  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_TEMPLATE_KEYWORD_060203_HPP
  7. #define BOOST_PARAMETER_TEMPLATE_KEYWORD_060203_HPP
  8. namespace boost { namespace parameter { namespace aux {
  9. struct template_keyword_base
  10. {
  11. };
  12. }}} // namespace boost::parameter::aux
  13. #include <boost/parameter/config.hpp>
  14. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  15. #include <type_traits>
  16. namespace boost { namespace parameter { namespace aux {
  17. template <typename T>
  18. using is_template_keyword = ::std::is_base_of<
  19. ::boost::parameter::aux::template_keyword_base
  20. , typename ::std::remove_const<
  21. typename ::std::remove_reference<T>::type
  22. >::type
  23. >;
  24. }}} // namespace boost::parameter::aux
  25. #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
  26. #include <boost/mpl/bool.hpp>
  27. #include <boost/mpl/if.hpp>
  28. #include <boost/type_traits/remove_const.hpp>
  29. #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
  30. #include <boost/type_traits/is_base_of.hpp>
  31. #include <boost/type_traits/remove_reference.hpp>
  32. #else
  33. #include <boost/type_traits/is_convertible.hpp>
  34. #include <boost/type_traits/is_lvalue_reference.hpp>
  35. #endif
  36. namespace boost { namespace parameter { namespace aux {
  37. #if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
  38. template <typename T>
  39. struct is_template_keyword_aux
  40. : ::boost::mpl::if_<
  41. ::boost::is_convertible<
  42. T*
  43. , ::boost::parameter::aux::template_keyword_base const*
  44. >
  45. , ::boost::mpl::true_
  46. , ::boost::mpl::false_
  47. >::type
  48. {
  49. };
  50. #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING
  51. template <typename T>
  52. struct is_template_keyword
  53. : ::boost::mpl::if_<
  54. #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
  55. // Cannot use is_convertible<> to check if T is derived from
  56. // template_keyword_base. -- Cromwell D. Enage
  57. ::boost::is_base_of<
  58. ::boost::parameter::aux::template_keyword_base
  59. , typename ::boost::remove_const<
  60. typename ::boost::remove_reference<T>::type
  61. >::type
  62. >
  63. , ::boost::mpl::true_
  64. , ::boost::mpl::false_
  65. #else
  66. ::boost::is_lvalue_reference<T>
  67. , ::boost::mpl::false_
  68. , ::boost::parameter::aux::is_template_keyword_aux<T>
  69. #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING
  70. >::type
  71. {
  72. };
  73. }}} // namespace boost::parameter::aux
  74. #endif // BOOST_PARAMETER_CAN_USE_MP11
  75. #endif // include guard