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 //===----------------------------------------------------------------------===//
10 // UNSUPPORTED: c++98, c++03
14 // add_rvalue_reference
15 // If T names a referenceable type then the member typedef type
16 // shall name T&&; otherwise, type shall name T.
18 #include <type_traits>
19 #include "test_macros.h"
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), "");
52 test_add_rvalue_reference<void, void>();
53 test_add_rvalue_reference<int, int&&>();
54 test_add_rvalue_reference<int[3], int(&&)[3]>();
55 test_add_rvalue_reference<int&, int&>();
56 test_add_rvalue_reference<const int&, const int&>();
57 test_add_rvalue_reference<int*, int*&&>();
58 test_add_rvalue_reference<const int*, const int*&&>();
59 test_add_rvalue_reference<Foo, Foo&&>();
61 // LWG 2101 specifically talks about add_rvalue_reference and functions.
62 // The term of art is "a referenceable type", which a cv- or ref-qualified function is not.
63 test_function0<void()>();
64 test_function1<void() const>();
65 test_function1<void() &>();
66 test_function1<void() &&>();
67 test_function1<void() const &>();
68 test_function1<void() const &&>();
70 // But a cv- or ref-qualified member function *is* "a referenceable type"
71 test_function0<void (Foo::*)()>();
72 test_function0<void (Foo::*)() const>();
73 test_function0<void (Foo::*)() &>();
74 test_function0<void (Foo::*)() &&>();
75 test_function0<void (Foo::*)() const &>();
76 test_function0<void (Foo::*)() const &&>();