brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 82bf213 Raw
55 lines · cpp
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-exception6//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++1718 19#include <functional>20#include <type_traits>21 22#include "test_macros.h"23 24 25template <typename T, typename Expected>26void 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 31template <typename T>32void 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 42struct T { };43 44int 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