//===----------------------------------------------------------------------===// // // 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 #include "test_macros.h" TEST_CLANG_DIAGNOSTIC_IGNORED("-Wsign-compare") TEST_GCC_DIAGNOSTIC_IGNORED("-Wsign-compare") TEST_MSVC_DIAGNOSTIC_IGNORED(4018 4389) // various "signed/unsigned mismatch" // constexpr auto end() const; // constexpr iterator end() const requires same_as; #include #include #include #include "types.h" template constexpr void testType(U u) { { std::ranges::iota_view io(T(0), u); assert(std::ranges::next(io.begin(), 10) == io.end()); } { std::ranges::iota_view io(T(10), u); assert(io.begin() == io.end()); assert(io.begin() == std::move(io).end()); } { const std::ranges::iota_view io(T(0), u); assert(std::ranges::next(io.begin(), 10) == io.end()); assert(std::ranges::next(io.begin(), 10) == std::move(io).end()); } { const std::ranges::iota_view io(T(10), u); assert(io.begin() == io.end()); } { std::ranges::iota_view io(T(0), std::unreachable_sentinel); assert(io.begin() != io.end()); assert(std::ranges::next(io.begin()) != io.end()); assert(std::ranges::next(io.begin(), 10) != io.end()); } { const std::ranges::iota_view io(T(0), std::unreachable_sentinel); assert(io.begin() != io.end()); assert(std::ranges::next(io.begin()) != io.end()); assert(std::ranges::next(io.begin(), 10) != io.end()); } } constexpr bool test() { testType(SomeInt(10)); testType(IntComparableWith(SomeInt(10))); testType(IntComparableWith(10)); testType(IntComparableWith(10)); testType(IntComparableWith(10)); testType(int(10)); testType(unsigned(10)); testType(unsigned(10)); testType(int(10)); testType(IntComparableWith(10)); testType(short(10)); testType(IntComparableWith(10)); testType(IntComparableWith(10)); return true; } int main(int, char**) { test(); static_assert(test()); return 0; }