//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14, c++17 // friend constexpr bool operator==(const iterator& x, const sentinel& y); #include #include #include #include #include "test_iterators.h" template constexpr void testOne() { using Sent = sentinel_wrapper; using Range = std::ranges::subrange; using SplitView = std::ranges::split_view>; static_assert(!std::ranges::common_range); { // simple test { int buffer[] = {0, 1, 2, -1, 4, 5, 6}; Range input(Iter{buffer}, Sent{Iter{buffer + 7}}); SplitView sv(input, -1); auto b = sv.begin(); auto e = sv.end(); assert(!(b == e)); assert(b != e); std::advance(b, 2); assert(b == e); assert(!(b != e)); } // iterator at trailing empty position should not equal to end { int buffer[] = {0, 1, 2, -1}; Range input(Iter{buffer}, Sent{Iter{buffer + 4}}); SplitView sv(input, -1); auto b = sv.begin(); auto e = sv.end(); ++b; // cur points to end but trailing_empty is true assert(b != e); assert(!(b == e)); ++b; assert(b == e); assert(!(b != e)); } } } constexpr bool test() { testOne>(); testOne>(); testOne>(); testOne>(); testOne(); return true; } int main(int, char**) { test(); static_assert(test()); return 0; }