1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // add_rvalue_reference
13 // If T names a referenceable type then the member typedef type
14 // shall name T&&; otherwise, type shall name T.
16 #include <type_traits>
17 #include "test_macros.h"
19 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
21 template <class T, class U>
22 void test_add_rvalue_reference()
24 static_assert((std::is_same<typename std::add_rvalue_reference<T>::type, U>::value), "");
26 static_assert((std::is_same<std::add_rvalue_reference_t<T>, U>::value), "");
33 static_assert((std::is_same<typename std::add_rvalue_reference<F>::type, F&&>::value), "");
35 static_assert((std::is_same<std::add_rvalue_reference_t<F>, F&&>::value), "");
42 static_assert((std::is_same<typename std::add_rvalue_reference<F>::type, F>::value), "");
44 static_assert((std::is_same<std::add_rvalue_reference_t<F>, F>::value), "");
47 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
53 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
54 test_add_rvalue_reference<void, void>();
55 test_add_rvalue_reference<int, int&&>();
56 test_add_rvalue_reference<int[3], int(&&)[3]>();
57 test_add_rvalue_reference<int&, int&>();
58 test_add_rvalue_reference<const int&, const int&>();
59 test_add_rvalue_reference<int*, int*&&>();
60 test_add_rvalue_reference<const int*, const int*&&>();
61 test_add_rvalue_reference<Foo, Foo&&>();
63 // LWG 2101 specifically talks about add_rvalue_reference and functions.
64 // The term of art is "a referenceable type", which a cv- or ref-qualified function is not.
65 test_function0<void()>();
66 #if TEST_STD_VER >= 11
67 test_function1<void() const>();
68 test_function1<void() &>();
69 test_function1<void() &&>();
70 test_function1<void() const &>();
71 test_function1<void() const &&>();
74 // But a cv- or ref-qualified member function *is* "a referenceable type"
75 test_function0<void (Foo::*)()>();
76 #if TEST_STD_VER >= 11
77 test_function0<void (Foo::*)() const>();
78 test_function0<void (Foo::*)() &>();
79 test_function0<void (Foo::*)() &&>();
80 test_function0<void (Foo::*)() const &>();
81 test_function0<void (Foo::*)() const &&>();