| 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_ref_decay; |
| 13 |
// |
| 14 |
// template <class T> |
| 15 |
// using unwrap_ref_decay_t = typename unwrap_ref_decay<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 Result> |
| 26 |
void check() { |
| 27 |
static_assert(std::is_same_v<typename std::unwrap_ref_decay<T>::type, Result>); |
| 28 |
static_assert(std::is_same_v<typename std::unwrap_ref_decay<T>::type, std::unwrap_ref_decay_t<T>>); |
| 29 |
} |
| 30 |
|
| 31 |
struct T { }; |
| 32 |
|
| 33 |
int main(int, char**) { |
| 34 |
check<T, T>(); |
| 35 |
check<T&, T>(); |
| 36 |
check<T const, T>(); |
| 37 |
check<T const&, T>(); |
| 38 |
check<T*, T*>(); |
| 39 |
check<T const*, T const*>(); |
| 40 |
check<T[3], T*>(); |
| 41 |
check<T const [3], T const*>(); |
| 42 |
check<T (), T (*)()>(); |
| 43 |
check<T (int) const, T (int) const>(); |
| 44 |
check<T (int) &, T (int) &>(); |
| 45 |
check<T (int) &&, T (int) &&>(); |
| 46 |
|
| 47 |
check<std::reference_wrapper<T>, T&>(); |
| 48 |
check<std::reference_wrapper<T>&, T&>(); |
| 49 |
check<std::reference_wrapper<T const>, T const&>(); |
| 50 |
check<std::reference_wrapper<T const>&, T const&>(); |
| 51 |
check<std::reference_wrapper<T*>, T*&>(); |
| 52 |
check<std::reference_wrapper<T*>&, T*&>(); |
| 53 |
check<std::reference_wrapper<T const*>, T const*&>(); |
| 54 |
check<std::reference_wrapper<T const*>&, T const*&>(); |
| 55 |
check<std::reference_wrapper<T[3]>, T (&)[3]>(); |
| 56 |
check<std::reference_wrapper<T[3]>&, T (&)[3]>(); |
| 57 |
check<std::reference_wrapper<T ()>, T (&)()>(); |
| 58 |
check<std::reference_wrapper<T ()>&, T (&)()>(); |
| 59 |
|
| 60 |
return 0; |
| 61 |
} |