summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities/function.objects/refwrap/unwrap_ref_decay.pass.cpp
blob: 1987898393cd13a8baa68d9735ddcc956156ffd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

// <functional>
//
// template <class T>
// struct unwrap_ref_decay;
//
// template <class T>
// using unwrap_ref_decay_t = typename unwrap_ref_decay<T>::type;

// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17

#include <functional>
#include <type_traits>


template <typename T, typename Result>
void check() {
  static_assert(std::is_same_v<typename std::unwrap_ref_decay<T>::type, Result>);
  static_assert(std::is_same_v<typename std::unwrap_ref_decay<T>::type, std::unwrap_ref_decay_t<T>>);
}

struct T { };

int main(int, char**) {
  check<T,             T>();
  check<T&,            T>();
  check<T const,       T>();
  check<T const&,      T>();
  check<T*,            T*>();
  check<T const*,      T const*>();
  check<T[3],          T*>();
  check<T const [3],   T const*>();
  check<T (),          T (*)()>();
  check<T (int) const, T (int) const>();
  check<T (int) &,     T (int) &>();
  check<T (int) &&,    T (int) &&>();

  check<std::reference_wrapper<T>,         T&>();
  check<std::reference_wrapper<T>&,        T&>();
  check<std::reference_wrapper<T const>,   T const&>();
  check<std::reference_wrapper<T const>&,  T const&>();
  check<std::reference_wrapper<T*>,        T*&>();
  check<std::reference_wrapper<T*>&,       T*&>();
  check<std::reference_wrapper<T const*>,  T const*&>();
  check<std::reference_wrapper<T const*>&, T const*&>();
  check<std::reference_wrapper<T[3]>,      T (&)[3]>();
  check<std::reference_wrapper<T[3]>&,     T (&)[3]>();
  check<std::reference_wrapper<T ()>,      T (&)()>();
  check<std::reference_wrapper<T ()>&,     T (&)()>();

  return 0;
}
OpenPOWER on IntegriCloud