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_ADD_MEMBER_VOLATILE_HPP 10 #define BOOST_CLBL_TRTS_ADD_MEMBER_VOLATILE_HPP 11 12 #include <boost/callable_traits/detail/core.hpp> 13 14 namespace boost { namespace callable_traits { 15 16 //[ add_member_volatile_hpp 17 /*` 18 [section:ref_add_member_volatile add_member_volatile] 19 [heading Header] 20 ``#include <boost/callable_traits/add_member_volatile.hpp>`` 21 [heading Definition] 22 */ 23 24 template<typename T> 25 using add_member_volatile_t = //see below 26 //<- 27 #ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS 28 29 detail::sfinae_try< 30 typename detail::traits<T>::add_member_volatile, 31 32 detail::fail_when_same<typename detail::traits<T>::add_member_volatile, 33 detail::abominable_functions_not_supported_on_this_compiler, 34 this_compiler_doesnt_support_abominable_function_types>, 35 36 detail::fail_if_invalid< 37 typename detail::traits<T>::add_member_volatile, 38 member_qualifiers_are_illegal_for_this_type>>; 39 #else 40 41 detail::try_but_fail_if_invalid< 42 typename detail::traits<T>::add_member_volatile, 43 member_qualifiers_are_illegal_for_this_type>; 44 45 #endif // #ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS 46 47 namespace detail { 48 49 template<typename T, typename = std::false_type> 50 struct add_member_volatile_impl {}; 51 52 template<typename T> 53 struct add_member_volatile_impl <T, typename std::is_same< 54 add_member_volatile_t<T>, detail::dummy>::type> 55 { 56 using type = add_member_volatile_t<T>; 57 }; 58 } 59 //-> 60 61 template<typename T> 62 struct add_member_volatile : detail::add_member_volatile_impl<T> {}; 63 64 //<- 65 }} // namespace boost::callable_traits 66 //-> 67 68 /*` 69 [heading Constraints] 70 * `T` must be a function type or a member function pointer type 71 * If `T` is a pointer, it may not be cv/ref qualified 72 73 [heading Behavior] 74 * A substitution failure occurs if the constraints are violated. 75 * Adds a member volatile qualifier to `T`, if not already present. 76 77 [heading Input/Output Examples] 78 [table 79 [[`T`] [`add_member_volatile_t<T>`]] 80 [[`int()`] [`int() volatile`]] 81 [[`int(foo::*)()`] [`int(foo::*)() volatile`]] 82 [[`int(foo::*)() &`] [`int(foo::*)() volatile &`]] 83 [[`int(foo::*)() &&`] [`int(foo::*)() volatile &&`]] 84 [[`int(foo::*)() const`] [`int(foo::*)() const volatile`]] 85 [[`int(foo::*)() transaction_safe`] [`int(foo::*)() volatile transaction_safe`]] 86 [[`int`] [(substitution failure)]] 87 [[`int (&)()`] [(substitution failure)]] 88 [[`int (*)()`] [(substitution failure)]] 89 [[`int foo::*`] [(substitution failure)]] 90 [[`int (foo::* const)()`] [(substitution failure)]] 91 ] 92 93 [heading Example Program] 94 [import ../example/add_member_volatile.cpp] 95 [add_member_volatile] 96 [endsect][/section:ref_add_member_volatile] 97 */ 98 //] 99 100 #endif 101