libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

unwrap_reference.pass.cpp (1266B)


      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_reference;
     14 //
     15 // template <class T>
     16 // using unwrap_reference_t = typename unwrap_reference<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 Expected>
     25 void check_equal() {
     26   static_assert(std::is_same_v<typename std::unwrap_reference<T>::type, Expected>);
     27   static_assert(std::is_same_v<typename std::unwrap_reference<T>::type, std::unwrap_reference_t<T>>);
     28 }
     29 
     30 template <typename T>
     31 void check() {
     32   check_equal<T, T>();
     33   check_equal<T&, T&>();
     34   check_equal<T const, T const>();
     35   check_equal<T const&, T const&>();
     36 
     37   check_equal<std::reference_wrapper<T>, T&>();
     38   check_equal<std::reference_wrapper<T const>, T const&>();
     39 }
     40 
     41 struct T { };
     42 
     43 int main() {
     44   check<T>();
     45   check<int>();
     46   check<float>();
     47 
     48   check<T*>();
     49   check<int*>();
     50   check<float*>();
     51 }