• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 Copyright Barrett Adair 2016-2017
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt)
5 */
6 
7 #include <type_traits>
8 #include <functional>
9 #include <tuple>
10 #include <boost/callable_traits/add_member_lvalue_reference.hpp>
11 #include "test.hpp"
12 
13 #ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS
main()14 int main(){ return 0; }
15 #else
16 
17 struct foo{};
18 
main()19 int main() {
20 
21     {
22         using f   = void(foo::*)();
23         using l   = void(foo::*)() &;
24         using r   = void(foo::*)() &&;
25         using c   = void(foo::*)() const;
26         using cl  = void(foo::*)() const &;
27         using cr  = void(foo::*)() const &&;
28         using v   = void(foo::*)() volatile;
29         using vl  = void(foo::*)() volatile &;
30         using vr  = void(foo::*)() volatile &&;
31         using cv  = void(foo::*)() const volatile;
32         using cvl = void(foo::*)() const volatile &;
33         using cvr = void(foo::*)() const volatile &&;
34 
35         CT_ASSERT(std::is_same<l,     TRAIT(add_member_lvalue_reference, f)>{});
36         CT_ASSERT(std::is_same<cl,    TRAIT(add_member_lvalue_reference, c)>{});
37         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, v)>{});
38         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, v)>{});
39         CT_ASSERT(std::is_same<cvl,   TRAIT(add_member_lvalue_reference, cv)>{});
40         CT_ASSERT(std::is_same<l,     TRAIT(add_member_lvalue_reference, l)>{});
41         CT_ASSERT(std::is_same<cl,    TRAIT(add_member_lvalue_reference, cl)>{});
42         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, vl)>{});
43         CT_ASSERT(std::is_same<cvl,   TRAIT(add_member_lvalue_reference, cvl)>{});
44         CT_ASSERT(!std::is_same<r,    TRAIT(add_member_lvalue_reference, r)>{});
45         CT_ASSERT(!std::is_same<cr,   TRAIT(add_member_lvalue_reference, cr)>{});
46         CT_ASSERT(!std::is_same<vr,   TRAIT(add_member_lvalue_reference, vr)>{});
47         CT_ASSERT(!std::is_same<cvr,  TRAIT(add_member_lvalue_reference, cvr)>{});
48     }
49 
50     {
51         using f   = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...);
52         using l   = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) &;
53         using r   = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) &&;
54         using c   = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const;
55         using cl  = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const &;
56         using cr  = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const &&;
57         using v   = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile;
58         using vl  = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile &;
59         using vr  = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) volatile &&;
60         using cv  = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile;
61         using cvl = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile &;
62         using cvr = void(BOOST_CLBL_TRTS_DEFAULT_VARARGS_CC foo::*)(...) const volatile &&;
63 
64         CT_ASSERT(std::is_same<l,     TRAIT(add_member_lvalue_reference, f)>{});
65         CT_ASSERT(std::is_same<cl,    TRAIT(add_member_lvalue_reference, c)>{});
66         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, v)>{});
67         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, v)>{});
68         CT_ASSERT(std::is_same<cvl,   TRAIT(add_member_lvalue_reference, cv)>{});
69         CT_ASSERT(std::is_same<l,     TRAIT(add_member_lvalue_reference, l)>{});
70         CT_ASSERT(std::is_same<cl,    TRAIT(add_member_lvalue_reference, cl)>{});
71         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, vl)>{});
72         CT_ASSERT(std::is_same<cvl,   TRAIT(add_member_lvalue_reference, cvl)>{});
73         CT_ASSERT(!std::is_same<r,    TRAIT(add_member_lvalue_reference, r)>{});
74         CT_ASSERT(!std::is_same<cr,   TRAIT(add_member_lvalue_reference, cr)>{});
75         CT_ASSERT(!std::is_same<vr,   TRAIT(add_member_lvalue_reference, vr)>{});
76         CT_ASSERT(!std::is_same<cvr,  TRAIT(add_member_lvalue_reference, cvr)>{});
77     }
78 
79     {
80         using f   = void(...);
81         using l   = void(...) &;
82         using r   = void(...) &&;
83         using c   = void(...) const;
84         using cl  = void(...) const &;
85         using cr  = void(...) const &&;
86         using v   = void(...) volatile;
87         using vl  = void(...) volatile &;
88         using vr  = void(...) volatile &&;
89         using cv  = void(...) const volatile;
90         using cvl = void(...) const volatile &;
91         using cvr = void(...) const volatile &&;
92 
93         CT_ASSERT(std::is_same<l,     TRAIT(add_member_lvalue_reference, f)>{});
94         CT_ASSERT(std::is_same<cl,    TRAIT(add_member_lvalue_reference, c)>{});
95         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, v)>{});
96         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, v)>{});
97         CT_ASSERT(std::is_same<cvl,   TRAIT(add_member_lvalue_reference, cv)>{});
98         CT_ASSERT(std::is_same<l,     TRAIT(add_member_lvalue_reference, l)>{});
99         CT_ASSERT(std::is_same<cl,    TRAIT(add_member_lvalue_reference, cl)>{});
100         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, vl)>{});
101         CT_ASSERT(std::is_same<cvl,   TRAIT(add_member_lvalue_reference, cvl)>{});
102         CT_ASSERT(!std::is_same<r,    TRAIT(add_member_lvalue_reference, r)>{});
103         CT_ASSERT(!std::is_same<cr,   TRAIT(add_member_lvalue_reference, cr)>{});
104         CT_ASSERT(!std::is_same<vr,   TRAIT(add_member_lvalue_reference, vr)>{});
105         CT_ASSERT(!std::is_same<cvr,  TRAIT(add_member_lvalue_reference, cvr)>{});
106     }
107 
108     #ifdef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE
109     {
110         using f   = void(...) transaction_safe;
111         using l   = void(...) & transaction_safe;
112         using r   = void(...) && transaction_safe;
113         using c   = void(...) const transaction_safe;
114         using cl  = void(...) const & transaction_safe;
115         using cr  = void(...) const && transaction_safe;
116         using v   = void(...) volatile transaction_safe;
117         using vl  = void(...) volatile & transaction_safe;
118         using vr  = void(...) volatile && transaction_safe;
119         using cv  = void(...) const volatile transaction_safe;
120         using cvl = void(...) const volatile & transaction_safe;
121         using cvr = void(...) const volatile && transaction_safe;
122 
123         CT_ASSERT(std::is_same<l,     TRAIT(add_member_lvalue_reference, f)>{});
124         CT_ASSERT(std::is_same<cl,    TRAIT(add_member_lvalue_reference, c)>{});
125         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, v)>{});
126         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, v)>{});
127         CT_ASSERT(std::is_same<cvl,   TRAIT(add_member_lvalue_reference, cv)>{});
128         CT_ASSERT(std::is_same<l,     TRAIT(add_member_lvalue_reference, l)>{});
129         CT_ASSERT(std::is_same<cl,    TRAIT(add_member_lvalue_reference, cl)>{});
130         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, vl)>{});
131         CT_ASSERT(std::is_same<cvl,   TRAIT(add_member_lvalue_reference, cvl)>{});
132         CT_ASSERT(!std::is_same<r,    TRAIT(add_member_lvalue_reference, r)>{});
133         CT_ASSERT(!std::is_same<cr,   TRAIT(add_member_lvalue_reference, cr)>{});
134         CT_ASSERT(!std::is_same<vr,   TRAIT(add_member_lvalue_reference, vr)>{});
135         CT_ASSERT(!std::is_same<cvr,  TRAIT(add_member_lvalue_reference, cvr)>{});
136 
137     }
138     #endif // #ifdef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE
139 
140     #ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES
141     {
142         using f   = void(...) noexcept;
143         using l   = void(...) & noexcept;
144         using r   = void(...) && noexcept;
145         using c   = void(...) const noexcept;
146         using cl  = void(...) const & noexcept;
147         using cr  = void(...) const && noexcept;
148         using v   = void(...) volatile noexcept;
149         using vl  = void(...) volatile & noexcept;
150         using vr  = void(...) volatile && noexcept;
151         using cv  = void(...) const volatile noexcept;
152         using cvl = void(...) const volatile & noexcept;
153         using cvr = void(...) const volatile && noexcept;
154 
155         CT_ASSERT(std::is_same<l,     TRAIT(add_member_lvalue_reference, f)>{});
156         CT_ASSERT(std::is_same<cl,    TRAIT(add_member_lvalue_reference, c)>{});
157         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, v)>{});
158         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, v)>{});
159         CT_ASSERT(std::is_same<cvl,   TRAIT(add_member_lvalue_reference, cv)>{});
160         CT_ASSERT(std::is_same<l,     TRAIT(add_member_lvalue_reference, l)>{});
161         CT_ASSERT(std::is_same<cl,    TRAIT(add_member_lvalue_reference, cl)>{});
162         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, vl)>{});
163         CT_ASSERT(std::is_same<cvl,   TRAIT(add_member_lvalue_reference, cvl)>{});
164         CT_ASSERT(!std::is_same<r,    TRAIT(add_member_lvalue_reference, r)>{});
165         CT_ASSERT(!std::is_same<cr,   TRAIT(add_member_lvalue_reference, cr)>{});
166         CT_ASSERT(!std::is_same<vr,   TRAIT(add_member_lvalue_reference, vr)>{});
167         CT_ASSERT(!std::is_same<cvr,  TRAIT(add_member_lvalue_reference, cvr)>{});
168     }
169     #endif // #ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES
170 
171     #ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES
172     #ifdef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE
173     {
174         using f   = void(...) transaction_safe noexcept;
175         using l   = void(...) & transaction_safe noexcept;
176         using r   = void(...) && transaction_safe noexcept;
177         using c   = void(...) const transaction_safe noexcept;
178         using cl  = void(...) const & transaction_safe noexcept;
179         using cr  = void(...) const && transaction_safe noexcept;
180         using v   = void(...) volatile transaction_safe noexcept;
181         using vl  = void(...) volatile & transaction_safe noexcept;
182         using vr  = void(...) volatile && transaction_safe noexcept;
183         using cv  = void(...) const volatile transaction_safe noexcept;
184         using cvl = void(...) const volatile & transaction_safe noexcept;
185         using cvr = void(...) const volatile && transaction_safe noexcept;
186 
187         CT_ASSERT(std::is_same<l,     TRAIT(add_member_lvalue_reference, f)>{});
188         CT_ASSERT(std::is_same<cl,    TRAIT(add_member_lvalue_reference, c)>{});
189         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, v)>{});
190         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, v)>{});
191         CT_ASSERT(std::is_same<cvl,   TRAIT(add_member_lvalue_reference, cv)>{});
192         CT_ASSERT(std::is_same<l,     TRAIT(add_member_lvalue_reference, l)>{});
193         CT_ASSERT(std::is_same<cl,    TRAIT(add_member_lvalue_reference, cl)>{});
194         CT_ASSERT(std::is_same<vl,    TRAIT(add_member_lvalue_reference, vl)>{});
195         CT_ASSERT(std::is_same<cvl,   TRAIT(add_member_lvalue_reference, cvl)>{});
196         CT_ASSERT(!std::is_same<r,    TRAIT(add_member_lvalue_reference, r)>{});
197         CT_ASSERT(!std::is_same<cr,   TRAIT(add_member_lvalue_reference, cr)>{});
198         CT_ASSERT(!std::is_same<vr,   TRAIT(add_member_lvalue_reference, vr)>{});
199         CT_ASSERT(!std::is_same<cvr,  TRAIT(add_member_lvalue_reference, cvr)>{});
200     }
201     #endif // #ifdef BOOST_CLBL_TRTS_ENABLE_TRANSACTION_SAFE
202     #endif // #ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES
203 }
204 
205 #endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS
206 
207