decay.pass.cpp (1145B)
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 // type_traits 11 12 // decay 13 14 #include <type_traits> 15 16 #include "test_macros.h" 17 18 template <class T, class U> 19 void test_decay() 20 { 21 static_assert((std::is_same<typename std::decay<T>::type, U>::value), ""); 22 #if TEST_STD_VER > 11 23 static_assert((std::is_same<std::decay_t<T>, U>::value), ""); 24 #endif 25 } 26 27 int main() 28 { 29 test_decay<void, void>(); 30 test_decay<int, int>(); 31 test_decay<const volatile int, int>(); 32 test_decay<int*, int*>(); 33 test_decay<int[3], int*>(); 34 test_decay<const int[3], const int*>(); 35 test_decay<void(), void (*)()>(); 36 #if TEST_STD_VER > 11 37 test_decay<int(int) const, int(int) const>(); 38 test_decay<int(int) volatile, int(int) volatile>(); 39 test_decay<int(int) &, int(int) &>(); 40 test_decay<int(int) &&, int(int) &&>(); 41 #endif 42 }