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