| 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 <boost/callable_traits/detail/config.hpp> |
| 8 | #ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS |
| 9 | int main(){ return 0; } |
| 10 | #else |
| 11 | |
| 12 | //[ add_member_rvalue_reference |
| 13 | #include <type_traits> |
| 14 | #include <boost/callable_traits/add_member_rvalue_reference.hpp> |
| 15 | |
| 16 | namespace ct = boost::callable_traits; |
| 17 | |
| 18 | struct foo {}; |
| 19 | |
| 20 | int main() { |
| 21 | |
| 22 | { |
| 23 | using pmf = void(foo::*)(); |
| 24 | using expect = void(foo::*)() &&; |
| 25 | using test = ct::add_member_rvalue_reference_t<pmf>; |
| 26 | static_assert(std::is_same<test, expect>::value, "" ); |
| 27 | } { |
| 28 | // add_member_rvalue_reference_t doesn't change anything when |
| 29 | // the function type already has an rvalue qualifier. |
| 30 | using pmf = void(foo::*)() &&; |
| 31 | using expect = void(foo::*)() &&; |
| 32 | using test = ct::add_member_rvalue_reference_t<pmf>; |
| 33 | static_assert(std::is_same<test, expect>::value, "" ); |
| 34 | } { |
| 35 | // add_member_rvalue_reference_t models C++11 reference collapsing |
| 36 | // rules, so that adding an rvalue qualifier to an |
| 37 | // lvalue-qualified type will not change anything. |
| 38 | using pmf = void(foo::*)() const &; |
| 39 | using expect = void(foo::*)() const &; |
| 40 | using test = ct::add_member_rvalue_reference_t<pmf>; |
| 41 | static_assert(std::is_same<test, expect>::value, "" ); |
| 42 | } { |
| 43 | // add_member_rvalue_reference_t can also be used with "abominable" |
| 44 | // function types. |
| 45 | using f = void() const; |
| 46 | using expect = void() const &&; |
| 47 | using test = ct::add_member_rvalue_reference_t<f>; |
| 48 | static_assert(std::is_same<test, expect>::value, "" ); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | //] |
| 53 | #endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS |
| 54 | |