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 <utility> 10 #include <boost/callable_traits/has_member_qualifiers.hpp> 11 #include "test.hpp" 12 13 14 #ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS main()15int main() { return 0; } 16 #else 17 18 struct foo {}; 19 20 template<typename T> assert_qualified()21void assert_qualified() { 22 CT_ASSERT( has_member_qualifiers<T>::value); 23 } 24 25 26 template<typename T> assert_unqualified()27void assert_unqualified() { 28 CT_ASSERT(! has_member_qualifiers<T>::value); 29 } 30 main()31int main() { 32 33 { 34 using f = void(foo::*)(); 35 using l = void(foo::*)() &; 36 using r = void(foo::*)() && ; 37 using c = void(foo::*)() const; 38 using cl = void(foo::*)() const &; 39 using cr = void(foo::*)() const &&; 40 using v = void(foo::*)() volatile; 41 using vl = void(foo::*)() volatile &; 42 using vr = void(foo::*)() volatile &&; 43 using cv = void(foo::*)() const volatile; 44 using cvl = void(foo::*)() const volatile &; 45 using cvr = void(foo::*)() const volatile &&; 46 47 assert_unqualified<f>(); 48 assert_qualified<l>(); 49 assert_qualified<r>(); 50 assert_qualified<c>(); 51 assert_qualified<cl>(); 52 assert_qualified<cr>(); 53 assert_qualified<v>(); 54 assert_qualified<vl>(); 55 assert_qualified<vr>(); 56 assert_qualified<cv>(); 57 assert_qualified<cvl>(); 58 assert_qualified<cvr>(); 59 } 60 61 { 62 struct f { int operator()() { return 0; } }; 63 struct l { int operator()() & { return 0; } }; 64 struct r { int operator()() && { return 0; } }; 65 struct c { int operator()() const { return 0; } }; 66 struct cl { int operator()() const & { return 0; } }; 67 struct cr { int operator()() const && { return 0; } }; 68 struct v { int operator()() volatile { return 0; } }; 69 struct vl { int operator()() volatile & { return 0; } }; 70 struct vr { int operator()() volatile && { return 0; } }; 71 struct cv { int operator()() const volatile { return 0; } }; 72 struct cvl { int operator()() const volatile & { return 0; } }; 73 struct cvr { int operator()() const volatile && { return 0; } }; 74 75 assert_unqualified<f>(); 76 assert_qualified<l>(); 77 assert_qualified<r>(); 78 assert_qualified<c>(); 79 assert_qualified<cl>(); 80 assert_qualified<cr>(); 81 assert_qualified<v>(); 82 assert_qualified<vl>(); 83 assert_qualified<vr>(); 84 assert_qualified<cv>(); 85 assert_qualified<cvl>(); 86 assert_qualified<cvr>(); 87 } 88 89 #ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS 90 91 { 92 using f = void(); 93 using l = void() &; 94 using r = void() && ; 95 using c = void() const; 96 using cl = void() const &; 97 using cr = void() const &&; 98 using v = void() volatile; 99 using vl = void() volatile &; 100 using vr = void() volatile &&; 101 using cv = void() const volatile; 102 using cvl = void() const volatile &; 103 using cvr = void() const volatile &&; 104 105 CT_ASSERT(! has_member_qualifiers<f>()); 106 CT_ASSERT( has_member_qualifiers<l>()); 107 CT_ASSERT( has_member_qualifiers<r>()); 108 CT_ASSERT( has_member_qualifiers<c>()); 109 CT_ASSERT( has_member_qualifiers<cl>()); 110 CT_ASSERT( has_member_qualifiers<cr>()); 111 CT_ASSERT( has_member_qualifiers<v>()); 112 CT_ASSERT( has_member_qualifiers<vl>()); 113 CT_ASSERT( has_member_qualifiers<vr>()); 114 CT_ASSERT( has_member_qualifiers<cv>()); 115 CT_ASSERT( has_member_qualifiers<cvl>()); 116 CT_ASSERT( has_member_qualifiers<cvr>()); 117 } 118 119 #endif //#ifndef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS 120 121 using f_ptr = void(*)(); 122 assert_unqualified<f_ptr>(); 123 assert_unqualified<f_ptr foo::*>(); 124 assert_unqualified<int foo::*>(); 125 assert_unqualified<void(&)()>(); 126 } 127 128 #endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS 129