[PassBuilder] VectorizerEnd Extension Points (#123494)
[llvm-project.git] / libcxx / test / std / containers / views / mdspan / default_accessor / access.pass.cpp
bloba15ad6895254e66f4a8049af4f825b77aa67e041
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
11 // <mdspan>
13 // constexpr reference access(data_handle_type p, size_t i) const noexcept;
15 // Effects: Equivalent to: return p[i];
17 #include <mdspan>
18 #include <cassert>
19 #include <type_traits>
21 #include "test_macros.h"
23 #include "../MinimalElementType.h"
25 template <class T>
26 constexpr void test_access() {
27 ElementPool<std::remove_const_t<T>, 10> data;
28 T* ptr = data.get_ptr();
29 std::default_accessor<T> acc;
30 for(int i = 0; i < 10; i++) {
31 static_assert(std::is_same_v<decltype(acc.access(ptr, i)), typename std::default_accessor<T>::reference>);
32 ASSERT_NOEXCEPT(acc.access(ptr, i));
33 assert(&acc.access(ptr, i) == ptr + i);
37 constexpr bool test() {
38 test_access<int>();
39 test_access<const int>();
40 test_access<MinimalElementType>();
41 test_access<const MinimalElementType>();
42 return true;
45 int main(int, char**) {
46 test();
47 static_assert(test());
48 return 0;