xref: /llvm-project/libcxx/test/libcxx/containers/views/mdspan/layout_right/assert.stride.pass.cpp (revision 58780b811c23df3d928d8452ee21c862dde754a2)
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 
9 // REQUIRES: has-unix-headers
10 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
11 // UNSUPPORTED: libcpp-hardening-mode=none
12 // XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing
13 
14 // <mdspan>
15 
16 // layout_right::mapping
17 //
18 // constexpr index_type stride(rank_type i) const noexcept;
19 //
20 //   Constraints: extents_type::rank() > 0 is true.
21 //
22 //   Preconditions: i < extents_type::rank() is true.
23 //
24 //   Returns: extents().rev-prod-of-extents(i).
25 //
26 //
27 
28 #include <mdspan>
29 #include <cassert>
30 
31 #include "check_assertion.h"
32 
main(int,char **)33 int main(int, char**) {
34   // value out of range
35   {
36     std::layout_right::mapping<std::dextents<int, 3>> m{std::dextents<int, 3>{100, 100, 100}};
37 
38     TEST_LIBCPP_ASSERT_FAILURE(m.stride(4), "layout_right::mapping::stride(): invalid rank index");
39   }
40   return 0;
41 }
42