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
11 // constexpr auto operator->() const noexcept
12 // requires contiguous_iterator<I>;
16 #include "test_macros.h"
17 #include "test_iterators.h"
20 concept ArrowEnabled
= requires(Iter
& iter
) {
24 constexpr bool test() {
25 int buffer
[8] = {1, 2, 3, 4, 5, 6, 7, 8};
28 std::counted_iterator
iter(contiguous_iterator
<int*>{buffer
}, 8);
29 for (int i
= 0; i
< 8; ++i
, ++iter
)
30 assert(iter
.operator->() == buffer
+ i
);
32 static_assert(noexcept(iter
.operator->()));
35 const std::counted_iterator
iter(contiguous_iterator
<int*>{buffer
}, 8);
36 assert(iter
.operator->() == buffer
);
38 static_assert(noexcept(iter
.operator->()));
42 static_assert( ArrowEnabled
<std::counted_iterator
<contiguous_iterator
<int*>>>);
43 static_assert(!ArrowEnabled
<std::counted_iterator
<random_access_iterator
<int*>>>);
49 int main(int, char**) {
51 static_assert(test());