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-exception
6//
7//===----------------------------------------------------------------------===//
8// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
9
10// <mdspan>
11
12// template <class... Integrals>
13// explicit extents(Integrals...) -> see below;
14// Constraints: (is_convertible_v<Integrals, size_t> && ...) is true.
15//
16// Remarks: The deduced type is dextents<size_t, sizeof...(Integrals)>.
17
18#include <mdspan>
19#include <cassert>
20
21#include "../ConvertibleToIntegral.h"
22#include "test_macros.h"
23
24struct NoDefaultCtorIndex {
25 size_t value;
26 constexpr NoDefaultCtorIndex() = delete;
27 constexpr NoDefaultCtorIndex(size_t val) : value(val) {}
28 constexpr operator size_t() const noexcept { return value; }
29};
30
31template <class E, class Expected>
32constexpr void test(E e, Expected expected) {
33 ASSERT_SAME_TYPE(E, Expected);
34 assert(e == expected);
35}
36
37constexpr bool test() {
38 constexpr std::size_t D = std::dynamic_extent;
39
40 test(std::extents(), std::extents<size_t>());
41 test(std::extents(1), std::extents<std::size_t, D>(1));
42 test(std::extents(1, 2u), std::extents<std::size_t, D, D>(1, 2u));
43 test(std::extents(1, 2u, 3, 4, 5, 6, 7, 8, 9),
44 std::extents<std::size_t, D, D, D, D, D, D, D, D, D>(1, 2u, 3, 4, 5, 6, 7, 8, 9));
45 test(std::extents(NoDefaultCtorIndex{1}, NoDefaultCtorIndex{2}), std::extents<std::size_t, D, D>(1, 2));
46 return true;
47}
48
49int main(int, char**) {
50 test();
51 static_assert(test());
52
53 return 0;
54}
55

source code of libcxx/test/std/containers/views/mdspan/extents/ctad.pass.cpp