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 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
12 // template<size_t Rank, class IndexType = size_t>
13 // using dims = see below;
15 // Result: A type E that is a specialization of extents such that
16 // E::rank() == Rank && E::rank() == E::rank_dynamic() is true,
17 // and E::index_type denotes IndexType.
21 #include <span> // dynamic_extent
23 #include "test_macros.h"
25 template <class IndexType
>
26 void test_alias_template_dims() {
27 constexpr size_t D
= std::dynamic_extent
;
28 ASSERT_SAME_TYPE(std::dims
<0, IndexType
>, std::extents
<IndexType
>);
29 ASSERT_SAME_TYPE(std::dims
<1, IndexType
>, std::extents
<IndexType
, D
>);
30 ASSERT_SAME_TYPE(std::dims
<2, IndexType
>, std::extents
<IndexType
, D
, D
>);
31 ASSERT_SAME_TYPE(std::dims
<3, IndexType
>, std::extents
<IndexType
, D
, D
, D
>);
32 ASSERT_SAME_TYPE(std::dims
<9, IndexType
>, std::extents
<IndexType
, D
, D
, D
, D
, D
, D
, D
, D
, D
>);
36 void test_alias_template_dims
<size_t>() {
37 constexpr size_t D
= std::dynamic_extent
;
38 ASSERT_SAME_TYPE(std::dims
<0>, std::extents
<size_t>);
39 ASSERT_SAME_TYPE(std::dims
<1>, std::extents
<size_t, D
>);
40 ASSERT_SAME_TYPE(std::dims
<2>, std::extents
<size_t, D
, D
>);
41 ASSERT_SAME_TYPE(std::dims
<3>, std::extents
<size_t, D
, D
, D
>);
42 ASSERT_SAME_TYPE(std::dims
<9>, std::extents
<size_t, D
, D
, D
, D
, D
, D
, D
, D
, D
>);
45 int main(int, char**) {
46 test_alias_template_dims
<int>();
47 test_alias_template_dims
<unsigned int>();
48 test_alias_template_dims
<size_t>();