• 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.hpp>
11 #include "test.hpp"
12 
13 #ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS
main()14 int main(){ return 0; }
15 #else
16 
17 
18 struct foo{};
19 
main()20 int main() {
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<r,    TRAIT(add_member_rvalue_reference, f)>{});
36         CT_ASSERT(std::is_same<cr,   TRAIT(add_member_rvalue_reference, c)>{});
37         CT_ASSERT(std::is_same<vr,   TRAIT(add_member_rvalue_reference, v)>{});
38         CT_ASSERT(std::is_same<cvr,  TRAIT(add_member_rvalue_reference, cv)>{});
39         CT_ASSERT(std::is_same<l,    TRAIT(add_member_rvalue_reference, l)>{});
40         CT_ASSERT(std::is_same<cl,   TRAIT(add_member_rvalue_reference, cl)>{});
41         CT_ASSERT(std::is_same<vl,   TRAIT(add_member_rvalue_reference, vl)>{});
42         CT_ASSERT(std::is_same<cvl,  TRAIT(add_member_rvalue_reference, cvl)>{});
43         CT_ASSERT(std::is_same<r,    TRAIT(add_member_rvalue_reference, r)>{});
44         CT_ASSERT(!std::is_same<r,   TRAIT(add_member_rvalue_reference, l)>{});
45         CT_ASSERT(std::is_same<cr,   TRAIT(add_member_rvalue_reference, cr)>{});
46         CT_ASSERT(std::is_same<vr,   TRAIT(add_member_rvalue_reference, vr)>{});
47         CT_ASSERT(std::is_same<cvr,  TRAIT(add_member_rvalue_reference, cvr)>{});
48     }
49 
50     {
51         using f   = void(foo::*)();
52         using l   = void(foo::*)() &;
53         using r   = void(foo::*)() &&;
54         using c   = void(foo::*)() const;
55         using cl  = void(foo::*)() const &;
56         using cr  = void(foo::*)() const &&;
57         using v   = void(foo::*)() volatile;
58         using vl  = void(foo::*)() volatile &;
59         using vr  = void(foo::*)() volatile &&;
60         using cv  = void(foo::*)() const volatile;
61         using cvl = void(foo::*)() const volatile &;
62         using cvr = void(foo::*)() const volatile &&;
63 
64         CT_ASSERT(std::is_same<r,    TRAIT(add_member_rvalue_reference, f)>{});
65         CT_ASSERT(std::is_same<cr,   TRAIT(add_member_rvalue_reference, c)>{});
66         CT_ASSERT(std::is_same<vr,   TRAIT(add_member_rvalue_reference, v)>{});
67         CT_ASSERT(std::is_same<cvr,  TRAIT(add_member_rvalue_reference, cv)>{});
68         CT_ASSERT(std::is_same<l,    TRAIT(add_member_rvalue_reference, l)>{});
69         CT_ASSERT(std::is_same<cl,   TRAIT(add_member_rvalue_reference, cl)>{});
70         CT_ASSERT(std::is_same<vl,   TRAIT(add_member_rvalue_reference, vl)>{});
71         CT_ASSERT(std::is_same<cvl,  TRAIT(add_member_rvalue_reference, cvl)>{});
72         CT_ASSERT(std::is_same<r,    TRAIT(add_member_rvalue_reference, r)>{});
73         CT_ASSERT(!std::is_same<r,   TRAIT(add_member_rvalue_reference, l)>{});
74         CT_ASSERT(std::is_same<cr,   TRAIT(add_member_rvalue_reference, cr)>{});
75         CT_ASSERT(std::is_same<vr,   TRAIT(add_member_rvalue_reference, vr)>{});
76         CT_ASSERT(std::is_same<cvr,  TRAIT(add_member_rvalue_reference, cvr)>{});
77     }
78 
79     {
80         using f   = void(foo::*)(...);
81         using l   = void(foo::*)(...) &;
82         using r   = void(foo::*)(...) &&;
83         using c   = void(foo::*)(...) const;
84         using cl  = void(foo::*)(...) const &;
85         using cr  = void(foo::*)(...) const &&;
86         using v   = void(foo::*)(...) volatile;
87         using vl  = void(foo::*)(...) volatile &;
88         using vr  = void(foo::*)(...) volatile &&;
89         using cv  = void(foo::*)(...) const volatile;
90         using cvl = void(foo::*)(...) const volatile &;
91         using cvr = void(foo::*)(...) const volatile &&;
92 
93         CT_ASSERT(std::is_same<r,    TRAIT(add_member_rvalue_reference, f)>{});
94         CT_ASSERT(std::is_same<cr,   TRAIT(add_member_rvalue_reference, c)>{});
95         CT_ASSERT(std::is_same<vr,   TRAIT(add_member_rvalue_reference, v)>{});
96         CT_ASSERT(std::is_same<cvr,  TRAIT(add_member_rvalue_reference, cv)>{});
97         CT_ASSERT(std::is_same<l,    TRAIT(add_member_rvalue_reference, l)>{});
98         CT_ASSERT(std::is_same<cl,   TRAIT(add_member_rvalue_reference, cl)>{});
99         CT_ASSERT(std::is_same<vl,   TRAIT(add_member_rvalue_reference, vl)>{});
100         CT_ASSERT(std::is_same<cvl,  TRAIT(add_member_rvalue_reference, cvl)>{});
101         CT_ASSERT(std::is_same<r,    TRAIT(add_member_rvalue_reference, r)>{});
102         CT_ASSERT(!std::is_same<r,   TRAIT(add_member_rvalue_reference, l)>{});
103         CT_ASSERT(std::is_same<cr,   TRAIT(add_member_rvalue_reference, cr)>{});
104         CT_ASSERT(std::is_same<vr,   TRAIT(add_member_rvalue_reference, vr)>{});
105         CT_ASSERT(std::is_same<cvr,  TRAIT(add_member_rvalue_reference, cvr)>{});
106     }
107 
108     {
109         using f   = void(foo::*)();
110         using l   = void(foo::*)() &;
111         using r   = void(foo::*)() &&;
112         using c   = void(foo::*)() const;
113         using cl  = void(foo::*)() const &;
114         using cr  = void(foo::*)() const &&;
115         using v   = void(foo::*)() volatile;
116         using vl  = void(foo::*)() volatile &;
117         using vr  = void(foo::*)() volatile &&;
118         using cv  = void(foo::*)() const volatile;
119         using cvl = void(foo::*)() const volatile &;
120         using cvr = void(foo::*)() const volatile &&;
121 
122         CT_ASSERT(std::is_same<r,    TRAIT(add_member_rvalue_reference, f)>{});
123         CT_ASSERT(std::is_same<cr,   TRAIT(add_member_rvalue_reference, c)>{});
124         CT_ASSERT(std::is_same<vr,   TRAIT(add_member_rvalue_reference, v)>{});
125         CT_ASSERT(std::is_same<cvr,  TRAIT(add_member_rvalue_reference, cv)>{});
126         CT_ASSERT(std::is_same<l,    TRAIT(add_member_rvalue_reference, l)>{});
127         CT_ASSERT(std::is_same<cl,   TRAIT(add_member_rvalue_reference, cl)>{});
128         CT_ASSERT(std::is_same<vl,   TRAIT(add_member_rvalue_reference, vl)>{});
129         CT_ASSERT(std::is_same<cvl,  TRAIT(add_member_rvalue_reference, cvl)>{});
130         CT_ASSERT(std::is_same<r,    TRAIT(add_member_rvalue_reference, r)>{});
131         CT_ASSERT(!std::is_same<r,   TRAIT(add_member_rvalue_reference, l)>{});
132         CT_ASSERT(std::is_same<cr,   TRAIT(add_member_rvalue_reference, cr)>{});
133         CT_ASSERT(std::is_same<vr,   TRAIT(add_member_rvalue_reference, vr)>{});
134         CT_ASSERT(std::is_same<cvr,  TRAIT(add_member_rvalue_reference, cvr)>{});
135     }
136 
137     {
138         using f   = void();
139         using l   = void() &;
140         using r   = void() &&;
141         using c   = void() const;
142         using cl  = void() const &;
143         using cr  = void() const &&;
144         using v   = void() volatile;
145         using vl  = void() volatile &;
146         using vr  = void() volatile &&;
147         using cv  = void() const volatile;
148         using cvl = void() const volatile &;
149         using cvr = void() const volatile &&;
150 
151         CT_ASSERT(std::is_same<r,    TRAIT(add_member_rvalue_reference, f)>{});
152         CT_ASSERT(std::is_same<cr,   TRAIT(add_member_rvalue_reference, c)>{});
153         CT_ASSERT(std::is_same<vr,   TRAIT(add_member_rvalue_reference, v)>{});
154         CT_ASSERT(std::is_same<cvr,  TRAIT(add_member_rvalue_reference, cv)>{});
155         CT_ASSERT(std::is_same<l,    TRAIT(add_member_rvalue_reference, l)>{});
156         CT_ASSERT(std::is_same<cl,   TRAIT(add_member_rvalue_reference, cl)>{});
157         CT_ASSERT(std::is_same<vl,   TRAIT(add_member_rvalue_reference, vl)>{});
158         CT_ASSERT(std::is_same<cvl,  TRAIT(add_member_rvalue_reference, cvl)>{});
159         CT_ASSERT(std::is_same<r,    TRAIT(add_member_rvalue_reference, r)>{});
160         CT_ASSERT(!std::is_same<r,   TRAIT(add_member_rvalue_reference, l)>{});
161         CT_ASSERT(std::is_same<cr,   TRAIT(add_member_rvalue_reference, cr)>{});
162         CT_ASSERT(std::is_same<vr,   TRAIT(add_member_rvalue_reference, vr)>{});
163         CT_ASSERT(std::is_same<cvr,  TRAIT(add_member_rvalue_reference, cvr)>{});
164     }
165 }
166 
167 #endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS
168