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