Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / iterators / predef.iterators / counted.iterator / arrow.pass.cpp
blob208d6932d86d6e6fa425068b6d69818fc519344b
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
11 // constexpr auto operator->() const noexcept
12 // requires contiguous_iterator<I>;
14 #include <iterator>
16 #include "test_macros.h"
17 #include "test_iterators.h"
19 template<class Iter>
20 concept ArrowEnabled = requires(Iter& iter) {
21 iter.operator->();
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*>>>);
46 return true;
49 int main(int, char**) {
50 test();
51 static_assert(test());
53 return 0;