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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
13 // constexpr reference access(data_handle_type p, size_t i) const noexcept;
15 // Effects: Equivalent to: return p[i];
19 #include <type_traits>
21 #include "test_macros.h"
23 #include "../MinimalElementType.h"
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() {
39 test_access
<const int>();
40 test_access
<MinimalElementType
>();
41 test_access
<const MinimalElementType
>();
45 int main(int, char**) {
47 static_assert(test());