set_function_qualifiers.hpp 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. @Copyright Barrett Adair 2015-2017
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  5. */
  6. #ifndef BOOST_CLBL_TRTS_DETAIL_SET_FUNCTION_QUALIFIERS_HPP
  7. #define BOOST_CLBL_TRTS_DETAIL_SET_FUNCTION_QUALIFIERS_HPP
  8. #include <boost/callable_traits/detail/qualifier_flags.hpp>
  9. #define BOOST_CLBL_TRTS_SET_FUNCTION_QUALIFIERS(QUAL) \
  10. template<typename Return, typename... Args> \
  11. struct set_function_qualifiers_t < \
  12. flag_map<int QUAL>::value, false, false, Return, Args...> { \
  13. using type = Return(Args...) QUAL; \
  14. }; \
  15. \
  16. template<typename Return, typename... Args> \
  17. struct set_function_qualifiers_t < \
  18. flag_map<int QUAL>::value, true, false, Return, Args...> { \
  19. using type = Return(Args...) QUAL \
  20. BOOST_CLBL_TRTS_TRANSACTION_SAFE_SPECIFIER; \
  21. }; \
  22. \
  23. template<typename Return, typename... Args> \
  24. struct set_function_qualifiers_t < \
  25. flag_map<int QUAL>::value, false, true, Return, Args...> { \
  26. using type = Return(Args...) QUAL \
  27. BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER; \
  28. }; \
  29. \
  30. template<typename Return, typename... Args> \
  31. struct set_function_qualifiers_t < \
  32. flag_map<int QUAL>::value, true, true, Return, Args...> { \
  33. using type = Return(Args...) QUAL \
  34. BOOST_CLBL_TRTS_TRANSACTION_SAFE_SPECIFIER \
  35. BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER; \
  36. }; \
  37. \
  38. template<typename Return, typename... Args> \
  39. struct set_varargs_function_qualifiers_t < \
  40. flag_map<int QUAL>::value, false, false, Return, Args...> { \
  41. using type = Return(Args..., ...) QUAL; \
  42. }; \
  43. \
  44. template<typename Return, typename... Args> \
  45. struct set_varargs_function_qualifiers_t < \
  46. flag_map<int QUAL>::value, true, false, Return, Args...> { \
  47. using type = Return(Args..., ...) QUAL \
  48. BOOST_CLBL_TRTS_TRANSACTION_SAFE_SPECIFIER; \
  49. }; \
  50. \
  51. template<typename Return, typename... Args> \
  52. struct set_varargs_function_qualifiers_t < \
  53. flag_map<int QUAL>::value, false, true, Return, Args...> { \
  54. using type = Return(Args..., ...) QUAL \
  55. BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER; \
  56. }; \
  57. \
  58. template<typename Return, typename... Args> \
  59. struct set_varargs_function_qualifiers_t < \
  60. flag_map<int QUAL>::value, true, true, Return, Args...> { \
  61. using type = Return(Args..., ...) QUAL \
  62. BOOST_CLBL_TRTS_TRANSACTION_SAFE_SPECIFIER \
  63. BOOST_CLBL_TRTS_NOEXCEPT_SPECIFIER; \
  64. } \
  65. /**/
  66. namespace boost { namespace callable_traits { namespace detail {
  67. template<qualifier_flags Applied, bool IsTransactionSafe,
  68. bool IsNoexcept, typename Return, typename... Args>
  69. struct set_function_qualifiers_t {
  70. using type = Return(Args...);
  71. };
  72. template<qualifier_flags Applied, bool IsTransactionSafe,
  73. bool IsNoexcept, typename Return, typename... Args>
  74. struct set_varargs_function_qualifiers_t {
  75. using type = Return(Args..., ...);
  76. };
  77. #ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
  78. BOOST_CLBL_TRTS_SET_FUNCTION_QUALIFIERS(const);
  79. BOOST_CLBL_TRTS_SET_FUNCTION_QUALIFIERS(volatile);
  80. BOOST_CLBL_TRTS_SET_FUNCTION_QUALIFIERS(const volatile);
  81. #ifndef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS
  82. BOOST_CLBL_TRTS_SET_FUNCTION_QUALIFIERS(&);
  83. BOOST_CLBL_TRTS_SET_FUNCTION_QUALIFIERS(&&);
  84. BOOST_CLBL_TRTS_SET_FUNCTION_QUALIFIERS(const &);
  85. BOOST_CLBL_TRTS_SET_FUNCTION_QUALIFIERS(const &&);
  86. BOOST_CLBL_TRTS_SET_FUNCTION_QUALIFIERS(volatile &);
  87. BOOST_CLBL_TRTS_SET_FUNCTION_QUALIFIERS(volatile &&);
  88. BOOST_CLBL_TRTS_SET_FUNCTION_QUALIFIERS(const volatile &);
  89. BOOST_CLBL_TRTS_SET_FUNCTION_QUALIFIERS(const volatile &&);
  90. #endif // #ifndef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS
  91. #endif // #ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
  92. template<qualifier_flags Flags, bool IsTransactionSafe, bool IsNoexcept,
  93. typename... Ts>
  94. using set_function_qualifiers =
  95. typename set_function_qualifiers_t<Flags, IsTransactionSafe, IsNoexcept,
  96. Ts...>::type;
  97. template<qualifier_flags Flags, bool IsTransactionSafe, bool IsNoexcept,
  98. typename... Ts>
  99. using set_varargs_function_qualifiers =
  100. typename set_varargs_function_qualifiers_t<Flags, IsTransactionSafe,
  101. IsNoexcept, Ts...>::type;
  102. }}} // namespace boost::callable_traits::detail
  103. #endif //BOOST_CLBL_TRTS_DETAIL_SET_FUNCTION_QUALIFIERS_HPP