parenthesized_return_type.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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_PREPROCESSOR_IMPL_PARENTHESIZED_RETURN_TYPE_HPP
  6. #define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_PARENTHESIZED_RETURN_TYPE_HPP
  7. namespace boost { namespace parameter { namespace aux {
  8. // A metafunction that transforms void(*)(T) -> identity<T>
  9. template <typename UnaryFunctionPointer>
  10. struct unaryfunptr_return_type;
  11. }}} // namespace boost::parameter::aux
  12. #include <boost/parameter/config.hpp>
  13. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  14. #include <boost/mp11/utility.hpp>
  15. #else
  16. #include <boost/mpl/identity.hpp>
  17. #endif
  18. namespace boost { namespace parameter { namespace aux {
  19. template <typename Arg>
  20. struct unaryfunptr_return_type<void(*)(Arg)>
  21. {
  22. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  23. using type = ::boost::mp11::mp_identity<Arg>;
  24. #else
  25. typedef ::boost::mpl::identity<Arg> type;
  26. #endif
  27. };
  28. template <>
  29. struct unaryfunptr_return_type<void(*)(void)>
  30. {
  31. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  32. using type = ::boost::mp11::mp_identity<void>;
  33. #else
  34. typedef ::boost::mpl::identity<void> type;
  35. #endif
  36. };
  37. }}} // namespace boost::parameter::aux
  38. #if !defined(BOOST_NO_SFINAE)
  39. #include <boost/core/enable_if.hpp>
  40. namespace boost { namespace parameter { namespace aux {
  41. template <typename Pred, typename Ret>
  42. struct unaryfunptr_return_type<void(*)(::boost::enable_if<Pred,Ret>)>
  43. {
  44. typedef ::boost::enable_if<Pred,Ret> type;
  45. };
  46. template <bool b, typename Ret>
  47. struct unaryfunptr_return_type<void(*)(::boost::enable_if_c<b,Ret>)>
  48. {
  49. typedef ::boost::enable_if_c<b,Ret> type;
  50. };
  51. template <typename Pred, typename Ret>
  52. struct unaryfunptr_return_type<void(*)(::boost::lazy_enable_if<Pred,Ret>)>
  53. {
  54. typedef ::boost::lazy_enable_if<Pred,Ret> type;
  55. };
  56. template <bool b, typename Ret>
  57. struct unaryfunptr_return_type<void(*)(::boost::lazy_enable_if_c<b,Ret>)>
  58. {
  59. typedef ::boost::lazy_enable_if_c<b,Ret> type;
  60. };
  61. template <typename Pred, typename Ret>
  62. struct unaryfunptr_return_type<void(*)(::boost::disable_if<Pred,Ret>)>
  63. {
  64. typedef ::boost::disable_if<Pred,Ret> type;
  65. };
  66. template <bool b, typename Ret>
  67. struct unaryfunptr_return_type<void(*)(::boost::disable_if_c<b,Ret>)>
  68. {
  69. typedef ::boost::disable_if_c<b,Ret> type;
  70. };
  71. template <typename B, typename Ret>
  72. struct unaryfunptr_return_type<void(*)(::boost::lazy_disable_if<B,Ret>)>
  73. {
  74. typedef ::boost::lazy_disable_if<B,Ret> type;
  75. };
  76. template <bool b, typename Ret>
  77. struct unaryfunptr_return_type<void(*)(::boost::lazy_disable_if_c<b,Ret>)>
  78. {
  79. typedef ::boost::lazy_disable_if_c<b,Ret> type;
  80. };
  81. }}} // namespace boost::parameter::aux
  82. #if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
  83. #include <type_traits>
  84. namespace boost { namespace parameter { namespace aux {
  85. template <bool b, typename Ret>
  86. struct unaryfunptr_return_type<void(*)(::std::enable_if<b,Ret>)>
  87. {
  88. typedef ::std::enable_if<b,Ret> type;
  89. };
  90. }}} // namespace boost::parameter::aux
  91. #endif // BOOST_NO_CXX11_HDR_TYPE_TRAITS
  92. #endif // BOOST_NO_SFINAE
  93. // A macro that takes a parenthesized C++ type name (T) and transforms it
  94. // into an un-parenthesized type expression equivalent to identity<T>.
  95. #define BOOST_PARAMETER_PARENTHESIZED_RETURN_TYPE(x) \
  96. ::boost::parameter::aux::unaryfunptr_return_type< void(*)x >::type
  97. #endif // include guard