73 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++14, c++1710 11// friend constexpr bool operator==(const inner-iterator& x, const inner-iterator& y);12// requires forward_range<Base>;13//14// friend constexpr bool operator==(const inner-iterator& x, default_sentinel_t);15 16#include <ranges>17 18#include <concepts>19#include <string_view>20 21#include "../types.h"22 23#include "test_range.h"24 25constexpr bool test() {26 // When `View` is a forward range, `inner-iterator` supports both overloads of `operator==`.27 {28 SplitViewForward v("abc def", " ");29 auto val = *v.begin();30 auto b = val.begin();31 std::same_as<std::default_sentinel_t> decltype(auto) e = val.end();32 33 // inner-iterator == inner-iterator34 {35 assert(b == b);36 assert(!(b != b));37 }38 39 // inner-iterator == default_sentinel40 {41 assert(!(b == e));42 assert(b != e);43 44 assert(!(b == std::default_sentinel));45 assert(b != std::default_sentinel);46 }47 }48 49 // When `View` is an input range, `inner-iterator only supports comparing an `inner-iterator` to the default sentinel.50 {51 SplitViewInput v("abc def", ' ');52 auto val = *v.begin();53 auto b = val.begin();54 std::same_as<std::default_sentinel_t> decltype(auto) e = val.end();55 56 static_assert(!weakly_equality_comparable_with<decltype(b), decltype(b)>);57 58 assert(!(b == std::default_sentinel));59 assert(b != std::default_sentinel);60 assert(!(b == e));61 assert(b != e);62 }63 64 return true;65}66 67int main(int, char**) {68 test();69 static_assert(test());70 71 return 0;72}73