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