[PassBuilder] VectorizerEnd Extension Points (#123494)
[llvm-project.git] / libcxx / test / std / containers / views / mdspan / layout_stride / deduction.pass.cpp
blob233eebff0ccd0f480832ca80c1a8e40e4ddf8fef
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 // ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-ctad-maybe-unsupported
11 // <mdspan>
13 #include <array>
14 #include <cassert>
15 #include <cstddef>
16 #include <cstdint>
17 #include <mdspan>
18 #include <span> // dynamic_extent
19 #include <utility>
21 #include "test_macros.h"
23 // mdspan
25 // layout_stride::mapping does not have explicit deduction guides,
26 // but implicit deduction guides for constructor taking extents and strides
27 // should work
29 constexpr bool test() {
30 constexpr size_t D = std::dynamic_extent;
32 ASSERT_SAME_TYPE(decltype(std::layout_stride::mapping(std::extents<int>(), std::array<unsigned, 0>())),
33 std::layout_stride::mapping<std::extents<int>>);
34 ASSERT_SAME_TYPE(decltype(std::layout_stride::mapping(std::extents<int, 4>(), std::array<char, 1>{1})),
35 std::layout_stride::mapping<std::extents<int, 4>>);
36 ASSERT_SAME_TYPE(decltype(std::layout_stride::mapping(std::extents<int, D>(), std::array<char, 1>{1})),
37 std::layout_stride::mapping<std::extents<int, D>>);
38 ASSERT_SAME_TYPE(
39 decltype(std::layout_stride::mapping(std::extents<unsigned, D, 3>(), std::array<std::int64_t, 2>{3, 100})),
40 std::layout_stride::mapping<std::extents<unsigned, D, 3>>);
42 ASSERT_SAME_TYPE(decltype(std::layout_stride::mapping(std::extents<int>(), std::span<unsigned, 0>())),
43 std::layout_stride::mapping<std::extents<int>>);
44 ASSERT_SAME_TYPE(decltype(std::layout_stride::mapping(std::extents<int, 4>(), std::declval<std::span<char, 1>>())),
45 std::layout_stride::mapping<std::extents<int, 4>>);
46 ASSERT_SAME_TYPE(decltype(std::layout_stride::mapping(std::extents<int, D>(), std::declval<std::span<char, 1>>())),
47 std::layout_stride::mapping<std::extents<int, D>>);
48 ASSERT_SAME_TYPE(
49 decltype(std::layout_stride::mapping(std::extents<unsigned, D, 3>(), std::declval<std::span<std::int64_t, 2>>())),
50 std::layout_stride::mapping<std::extents<unsigned, D, 3>>);
51 return true;
54 int main(int, char**) {
55 test();
56 static_assert(test());
57 return 0;