has_nested_template_fn.hpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // Copyright Cromwell D. Enage 2019.
  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_HAS_NESTED_TEMPLATE_FN_HPP
  6. #define BOOST_PARAMETER_AUX_HAS_NESTED_TEMPLATE_FN_HPP
  7. #include <boost/parameter/aux_/yesno.hpp>
  8. #include <boost/parameter/aux_/preprocessor/nullptr.hpp>
  9. #include <boost/parameter/config.hpp>
  10. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  11. #include <boost/mp11/integral.hpp>
  12. #include <boost/mp11/utility.hpp>
  13. #else
  14. #include <boost/mpl/bool.hpp>
  15. #include <boost/mpl/identity.hpp>
  16. #endif
  17. namespace boost { namespace parameter { namespace aux {
  18. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  19. template <template <typename ...> class F>
  20. struct has_nested_template_fn_variadic
  21. {
  22. };
  23. #else
  24. template <template <typename P0, typename P1> class F>
  25. struct has_nested_template_fn_arity_2
  26. {
  27. };
  28. #endif
  29. template <typename T>
  30. class has_nested_template_fn_impl
  31. {
  32. template <typename U>
  33. static ::boost::parameter::aux::no_tag _check(...);
  34. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  35. template <typename U>
  36. static ::boost::parameter::aux::yes_tag
  37. _check(
  38. ::boost::mp11::mp_identity<U> const volatile*
  39. , ::boost::parameter::aux::has_nested_template_fn_variadic<
  40. U::template fn
  41. >* = BOOST_PARAMETER_AUX_PP_NULLPTR
  42. );
  43. #else
  44. template <typename U>
  45. static BOOST_CONSTEXPR ::boost::parameter::aux::yes_tag
  46. _check(
  47. ::boost::mpl::identity<U> const volatile*
  48. , ::boost::parameter::aux::has_nested_template_fn_arity_2<
  49. U::template fn
  50. >* = BOOST_PARAMETER_AUX_PP_NULLPTR
  51. );
  52. #endif
  53. public:
  54. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  55. using type = ::boost::mp11::mp_bool<
  56. #else
  57. typedef ::boost::mpl::bool_<
  58. #endif
  59. sizeof(
  60. ::boost::parameter::aux::has_nested_template_fn_impl<T>
  61. ::template _check<T>(
  62. static_cast<
  63. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  64. ::boost::mp11::mp_identity<T> const volatile*
  65. #else
  66. ::boost::mpl::identity<T> const volatile*
  67. #endif
  68. >(BOOST_PARAMETER_AUX_PP_NULLPTR)
  69. )
  70. ) == sizeof(::boost::parameter::aux::yes_tag)
  71. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  72. >;
  73. #else
  74. > type;
  75. #endif
  76. };
  77. }}} // namespace boost::parameter::aux
  78. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  79. #include <type_traits>
  80. #else
  81. #include <boost/type_traits/remove_const.hpp>
  82. #endif
  83. namespace boost { namespace parameter { namespace aux {
  84. template <typename T>
  85. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  86. using has_nested_template_fn = typename ::boost::parameter::aux
  87. ::has_nested_template_fn_impl<typename ::std::remove_const<T>::type>
  88. ::type;
  89. #else
  90. struct has_nested_template_fn
  91. : ::boost::parameter::aux::has_nested_template_fn_impl<
  92. typename ::boost::remove_const<T>::type
  93. >::type
  94. {
  95. };
  96. #endif
  97. }}} // namespace boost::parameter::aux
  98. #endif // include guard