• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 
3 @Copyright Barrett Adair 2015-2017
4 
5 Distributed under the Boost Software License, Version 1.0.
6 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
7 
8 */
9 
10 #ifndef BOOST_CLBL_TRTS_IS_REFERENCE_MEMBER_HPP
11 #define BOOST_CLBL_TRTS_IS_REFERENCE_MEMBER_HPP
12 
13 #include <boost/callable_traits/detail/core.hpp>
14 
15 namespace boost { namespace callable_traits {
16 
17 //[ is_reference_member_hpp
18 /*`[section:ref_is_reference_member is_reference_member]
19 [heading Header]
20 ``#include <boost/callable_traits/is_reference_member.hpp>``
21 [heading Definition]
22 */
23 
24 
25 // inherits from either std::true_type or std::false_type
26 template<typename T>
27 struct is_reference_member;
28 
29 //<-
30 template<typename T>
31 struct is_reference_member : detail::traits<
32     detail::shallow_decay<T>>::is_reference_member {
33 
34     using type = typename detail::traits<
35         detail::shallow_decay<T>>::is_reference_member;
36 };
37 
38 #ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES
39 
40 template<typename T>
41 struct is_reference_member_v {
42     static_assert(std::is_same<T, detail::dummy>::value,
43         "Variable templates not supported on this compiler.");
44 };
45 
46 #else
47 //->
48 // only available when variable templates are supported
49 template<typename T>
50 //<-
51 BOOST_CLBL_TRAITS_INLINE_VAR
52 //->
53 constexpr bool is_reference_member_v = //see below
54 //<-
55     detail::traits<detail::shallow_decay<T>>::is_reference_member::value;
56 
57 #endif
58 
59 }} // namespace boost::callable_traits
60 //->
61 
62 /*`
63 [heading Constraints]
64 * none
65 
66 [heading Behavior]
67 * `is_reference_member<T>::value` is `true` when either:
68   * `T` is a function type with a '&' or '&&' member qualifier
69   * `T` is a pointer to a member function with a '&' or '&&' member qualifiers
70   * `T` is a function object with a non-overloaded `operator()`, where the `operator()` has a '&' or '&&' member qualifier
71 * On compilers that support variable templates, `is_reference_member_v<T>` is equivalent to `is_reference_member<T>::value`.
72 
73 [heading Input/Output Examples]
74 [table
75     [[`T`]                              [`is_reference_member_v<T>`]]
76     [[`int() &`]                        [`true`]]
77     [[`int() const &&`]                 [`true`]]
78     [[`int(foo::* const)() &&`]         [`true`]]
79     [[`int(foo::*)(...) volatile &`]    [`true`]]
80     [[`int() const`]                    [`false`]]
81     [[`int() volatile`]                 [`false`]]
82     [[`int(foo::*)() const`]            [`false`]]
83     [[`int() const`]                    [`false`]]
84     [[`int() volatile`]                 [`false`]]
85     [[`int(*)()`]                       [`false`]]
86     [[`int`]                            [`false`]]
87     [[`int foo::*`]                     [`false`]]
88     [[`const int foo::*`]               [`false`]]
89 ]
90 
91 [heading Example Program]
92 [import ../example/is_reference_member.cpp]
93 [is_reference_member]
94 [endsect]
95 */
96 //]
97 
98 #endif // #ifndef BOOST_CLBL_TRTS_IS_REFERENCE_MEMBER_HPP
99