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 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: c++03, c++11, c++14, c++17 10 // UNSUPPORTED: libcpp-no-concepts 11 // UNSUPPORTED: libcpp-has-no-incomplete-ranges 12 13 #include "test_macros.h" 14 15 #if defined(TEST_COMPILER_CLANG) || defined(TEST_COMPILER_GCC) 16 #pragma GCC diagnostic ignored "-Wsign-compare" 17 #elif defined(TEST_COMPILER_MSVC) 18 #pragma warning(disable: 4018 4389) // various "signed/unsigned mismatch" 19 #endif 20 21 // constexpr iota_view(type_identity_t<W> value, type_identity_t<Bound> bound); 22 23 #include <ranges> 24 #include <cassert> 25 26 #include "types.h" 27 28 constexpr bool test() { 29 { 30 std::ranges::iota_view<SomeInt, SomeInt> io(SomeInt(0), SomeInt(10)); 31 assert(std::ranges::next(io.begin(), 10) == io.end()); 32 } 33 34 { 35 std::ranges::iota_view<SomeInt> io(SomeInt(0), std::unreachable_sentinel); 36 assert(std::ranges::next(io.begin(), 10) != io.end()); 37 } 38 39 { 40 std::ranges::iota_view<SomeInt, IntComparableWith<SomeInt>> io(SomeInt(0), IntComparableWith(SomeInt(10))); 41 assert(std::ranges::next(io.begin(), 10) == io.end()); 42 } 43 44 { 45 // This is allowed only when using the constructor (not the deduction guide). 46 std::ranges::iota_view<int, unsigned> signedUnsigned(0, 10); 47 assert(std::ranges::next(signedUnsigned.begin(), 10) == signedUnsigned.end()); 48 } 49 50 { 51 // This is allowed only when using the constructor (not the deduction guide). 52 std::ranges::iota_view<unsigned, int> signedUnsigned(0, 10); 53 assert(std::ranges::next(signedUnsigned.begin(), 10) == signedUnsigned.end()); 54 } 55 56 return true; 57 } 58 59 int main(int, char**) { 60 test(); 61 static_assert(test()); 62 63 return 0; 64 } 65