1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 #include <type_traits>
15 #include "test_macros.h"
17 template <class T
, unsigned A
>
20 static_assert((std::extent
<T
>::value
== A
), "");
21 static_assert((std::extent
<const T
>::value
== A
), "");
22 static_assert((std::extent
<volatile T
>::value
== A
), "");
23 static_assert((std::extent
<const volatile T
>::value
== A
), "");
25 static_assert((std::extent_v
<T
> == A
), "");
26 static_assert((std::extent_v
<const T
> == A
), "");
27 static_assert((std::extent_v
<volatile T
> == A
), "");
28 static_assert((std::extent_v
<const volatile T
> == A
), "");
32 template <class T
, unsigned A
>
35 static_assert((std::extent
<T
, 1>::value
== A
), "");
36 static_assert((std::extent
<const T
, 1>::value
== A
), "");
37 static_assert((std::extent
<volatile T
, 1>::value
== A
), "");
38 static_assert((std::extent
<const volatile T
, 1>::value
== A
), "");
40 static_assert((std::extent_v
<T
, 1> == A
), "");
41 static_assert((std::extent_v
<const T
, 1> == A
), "");
42 static_assert((std::extent_v
<volatile T
, 1> == A
), "");
43 static_assert((std::extent_v
<const volatile T
, 1> == A
), "");
55 test_extent
<void, 0>();
56 test_extent
<int&, 0>();
57 test_extent
<Class
, 0>();
58 test_extent
<int*, 0>();
59 test_extent
<const int*, 0>();
60 test_extent
<int, 0>();
61 test_extent
<double, 0>();
62 test_extent
<bool, 0>();
63 test_extent
<unsigned, 0>();
65 test_extent
<int[2], 2>();
66 test_extent
<int[2][4], 2>();
67 test_extent
<int[][4], 0>();
69 test_extent1
<int, 0>();
70 test_extent1
<int[2], 0>();
71 test_extent1
<int[2][4], 4>();
72 test_extent1
<int[][4], 4>();