• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <functional>
11 //
12 // template <class T>
13 // struct unwrap_ref_decay;
14 //
15 // template <class T>
16 // using unwrap_ref_decay_t = typename unwrap_ref_decay<T>::type;
17 
18 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
19 
20 #include <functional>
21 #include <type_traits>
22 
23 
24 template <typename T, typename Result>
check()25 void check() {
26   static_assert(std::is_same_v<typename std::unwrap_ref_decay<T>::type, Result>);
27   static_assert(std::is_same_v<typename std::unwrap_ref_decay<T>::type, std::unwrap_ref_decay_t<T>>);
28 }
29 
30 struct T { };
31 
main()32 int main() {
33   check<T,             T>();
34   check<T&,            T>();
35   check<T const,       T>();
36   check<T const&,      T>();
37   check<T*,            T*>();
38   check<T const*,      T const*>();
39   check<T[3],          T*>();
40   check<T const [3],   T const*>();
41   check<T (),          T (*)()>();
42   check<T (int) const, T (int) const>();
43   check<T (int) &,     T (int) &>();
44   check<T (int) &&,    T (int) &&>();
45 
46   check<std::reference_wrapper<T>,         T&>();
47   check<std::reference_wrapper<T>&,        T&>();
48   check<std::reference_wrapper<T const>,   T const&>();
49   check<std::reference_wrapper<T const>&,  T const&>();
50   check<std::reference_wrapper<T*>,        T*&>();
51   check<std::reference_wrapper<T*>&,       T*&>();
52   check<std::reference_wrapper<T const*>,  T const*&>();
53   check<std::reference_wrapper<T const*>&, T const*&>();
54   check<std::reference_wrapper<T[3]>,      T (&)[3]>();
55   check<std::reference_wrapper<T[3]>&,     T (&)[3]>();
56   check<std::reference_wrapper<T ()>,      T (&)()>();
57   check<std::reference_wrapper<T ()>&,     T (&)()>();
58 }
59