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#include "test_macros.h" 17 18template <class T, unsigned A> 19void test_extent() 20{ 21 static_assert((std::extent<T>::value == A), ""); 22 static_assert((std::extent<const T>::value == A), ""); 23 static_assert((std::extent<volatile T>::value == A), ""); 24 static_assert((std::extent<const volatile T>::value == A), ""); 25#if TEST_STD_VER > 14 26 static_assert((std::extent_v<T> == A), ""); 27 static_assert((std::extent_v<const T> == A), ""); 28 static_assert((std::extent_v<volatile T> == A), ""); 29 static_assert((std::extent_v<const volatile T> == A), ""); 30#endif 31} 32 33template <class T, unsigned A> 34void test_extent1() 35{ 36 static_assert((std::extent<T, 1>::value == A), ""); 37 static_assert((std::extent<const T, 1>::value == A), ""); 38 static_assert((std::extent<volatile T, 1>::value == A), ""); 39 static_assert((std::extent<const volatile T, 1>::value == A), ""); 40#if TEST_STD_VER > 14 41 static_assert((std::extent_v<T, 1> == A), ""); 42 static_assert((std::extent_v<const T, 1> == A), ""); 43 static_assert((std::extent_v<volatile T, 1> == A), ""); 44 static_assert((std::extent_v<const volatile T, 1> == A), ""); 45#endif 46} 47 48class Class 49{ 50public: 51 ~Class(); 52}; 53 54int main() 55{ 56 test_extent<void, 0>(); 57 test_extent<int&, 0>(); 58 test_extent<Class, 0>(); 59 test_extent<int*, 0>(); 60 test_extent<const int*, 0>(); 61 test_extent<int, 0>(); 62 test_extent<double, 0>(); 63 test_extent<bool, 0>(); 64 test_extent<unsigned, 0>(); 65 66 test_extent<int[2], 2>(); 67 test_extent<int[2][4], 2>(); 68 test_extent<int[][4], 0>(); 69 70 test_extent1<int, 0>(); 71 test_extent1<int[2], 0>(); 72 test_extent1<int[2][4], 4>(); 73 test_extent1<int[][4], 4>(); 74} 75