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
9 // ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-ctad-maybe-unsupported
18 #include <span> // dynamic_extent
21 #include "test_macros.h"
25 // layout_stride::mapping does not have explicit deduction guides,
26 // but implicit deduction guides for constructor taking extents and strides
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
>>);
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
>>);
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>>);
54 int main(int, char**) {
56 static_assert(test());