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 // extent 13 14 #include <type_traits> 15 16 template <class T, unsigned A> 17 void test_extent() 18 { 19 static_assert((std::extent<T>::value == A), ""); 20 static_assert((std::extent<const T>::value == A), ""); 21 static_assert((std::extent<volatile T>::value == A), ""); 22 static_assert((std::extent<const volatile T>::value == A), ""); 23 } 24 25 template <class T, unsigned A> 26 void test_extent1() 27 { 28 static_assert((std::extent<T, 1>::value == A), ""); 29 static_assert((std::extent<const T, 1>::value == A), ""); 30 static_assert((std::extent<volatile T, 1>::value == A), ""); 31 static_assert((std::extent<const volatile T, 1>::value == A), ""); 32 } 33 34 class Class 35 { 36 public: 37 ~Class(); 38 }; 39 40 int main() 41 { 42 test_extent<void, 0>(); 43 test_extent<int&, 0>(); 44 test_extent<Class, 0>(); 45 test_extent<int*, 0>(); 46 test_extent<const int*, 0>(); 47 test_extent<int, 0>(); 48 test_extent<double, 0>(); 49 test_extent<bool, 0>(); 50 test_extent<unsigned, 0>(); 51 52 test_extent<int[2], 2>(); 53 test_extent<int[2][4], 2>(); 54 test_extent<int[][4], 0>(); 55 56 test_extent1<int, 0>(); 57 test_extent1<int[2], 0>(); 58 test_extent1<int[2][4], 4>(); 59 test_extent1<int[][4], 4>(); 60 } 61