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