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_IS_CONST_MEMBER_HPP 10 #define BOOST_CLBL_TRTS_IS_CONST_MEMBER_HPP 11 12 #include <boost/callable_traits/detail/core.hpp> 13 14 namespace boost { namespace callable_traits { 15 16 //[ is_const_member_hpp 17 /*`[section:ref_is_const_member is_const_member] 18 [heading Header] 19 ``#include <boost/callable_traits/is_const_member.hpp>`` 20 [heading Definition] 21 */ 22 23 // inherits from either std::true_type or std::false_type 24 template<typename T> 25 struct is_const_member; 26 27 //<- 28 template<typename T> 29 struct is_const_member 30 : detail::traits<detail::shallow_decay<T>>::is_const_member { 31 using type = typename detail::traits< 32 detail::shallow_decay<T>>::is_const_member; 33 }; 34 35 #ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES 36 37 template<typename T> 38 struct is_const_member_v { 39 static_assert(std::is_same<T, detail::dummy>::value, 40 "Variable templates not supported on this compiler."); 41 }; 42 43 #else 44 //-> 45 // only available when variable templates are supported 46 template<typename T> 47 //<- 48 BOOST_CLBL_TRAITS_INLINE_VAR 49 //-> 50 constexpr bool is_const_member_v = //see below 51 //<- 52 detail::traits<detail::shallow_decay<T>>::is_const_member::value; 53 54 #endif 55 56 }} // namespace boost::callable_traits 57 //-> 58 59 /*` 60 [heading Constraints] 61 * none 62 63 [heading Behavior] 64 * `is_const_member<T>::value` is `true` when either: 65 * `T` is a function type with a `const` member qualifier 66 * `T` is a pointer to a member function with a `const` member qualifier 67 * `T` is a function object with a non-overloaded `operator()`, where the `operator()` has a `const` member qualifier 68 * On compilers that support variable templates, `is_const_member_v<T>` is equivalent to `is_const_member<T>::value`. 69 70 [heading Input/Output Examples] 71 [table 72 [[`T`] [`is_const_member_v<T>`]] 73 [[`int() const`] [`true`]] 74 [[`int() const volatile`] [`true`]] 75 [[`int() const & transaction_safe`] [`true`]] 76 [[`int() const &&`] [`true`]] 77 [[`int(foo::*&)() const`] [`true`]] 78 [[`int(foo::*)() const volatile`] [`true`]] 79 [[`int(foo::*)() const volatile &&`][`true`]] 80 [[`int(foo::* const)() const`] [`true`]] 81 [[`int()`] [`false`]] 82 [[`int() volatile`] [`false`]] 83 [[`int() &&`] [`false`]] 84 [[`int(*)()`] [`false`]] 85 [[`int`] [`false`]] 86 [[`int foo::*`] [`false`]] 87 [[`const int foo::*`] [`false`]] 88 ] 89 90 [heading Example Program] 91 [import ../example/is_const_member.cpp] 92 [is_const_member] 93 [endsect] 94 */ 95 //] 96 97 #endif // #ifndef BOOST_CLBL_TRTS_IS_CONST_MEMBER_HPP 98