1 | //===----------------------------------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // <functional> |
10 | // |
11 | // template <class T> |
12 | // struct unwrap_reference; |
13 | // |
14 | // template <class T> |
15 | // using unwrap_reference_t = typename unwrap_reference<T>::type; |
16 | |
17 | // UNSUPPORTED: c++03, c++11, c++14, c++17 |
18 | |
19 | #include <functional> |
20 | #include <type_traits> |
21 | |
22 | #include "test_macros.h" |
23 | |
24 | |
25 | template <typename T, typename Expected> |
26 | void check_equal() { |
27 | static_assert(std::is_same_v<typename std::unwrap_reference<T>::type, Expected>); |
28 | static_assert(std::is_same_v<typename std::unwrap_reference<T>::type, std::unwrap_reference_t<T>>); |
29 | } |
30 | |
31 | template <typename T> |
32 | void check() { |
33 | check_equal<T, T>(); |
34 | check_equal<T&, T&>(); |
35 | check_equal<T const, T const>(); |
36 | check_equal<T const&, T const&>(); |
37 | |
38 | check_equal<std::reference_wrapper<T>, T&>(); |
39 | check_equal<std::reference_wrapper<T const>, T const&>(); |
40 | } |
41 | |
42 | struct T { }; |
43 | |
44 | int main(int, char**) { |
45 | check<T>(); |
46 | check<int>(); |
47 | check<float>(); |
48 | |
49 | check<T*>(); |
50 | check<int*>(); |
51 | check<float*>(); |
52 | |
53 | return 0; |
54 | } |
55 | |