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 // add_volatile 13 14 #include <type_traits> 15 16 template <class T, class U> 17 void test_add_volatile_imp() 18 { 19 static_assert((std::is_same<typename std::add_volatile<T>::type, volatile U>::value), ""); 20 #if _LIBCPP_STD_VER > 11 21 static_assert((std::is_same<std::add_volatile_t<T>, U>::value), ""); 22 #endif 23 } 24 25 template <class T> 26 void test_add_volatile() 27 { 28 test_add_volatile_imp<T, volatile T>(); 29 test_add_volatile_imp<const T, const volatile T>(); 30 test_add_volatile_imp<volatile T, volatile T>(); 31 test_add_volatile_imp<const volatile T, const volatile T>(); 32 } 33 34 int main() 35 { 36 test_add_volatile<void>(); 37 test_add_volatile<int>(); 38 test_add_volatile<int[3]>(); 39 test_add_volatile<int&>(); 40 test_add_volatile<const int&>(); 41 test_add_volatile<int*>(); 42 test_add_volatile<const int*>(); 43 } 44