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-has-no-incomplete-ranges
11 
12 // constexpr iota_view(iterator first, see below last);
13 
14 #include <ranges>
15 #include <cassert>
16 
17 #include "test_macros.h"
18 #include "types.h"
19 
test()20 constexpr bool test() {
21   {
22     std::ranges::iota_view commonView(SomeInt(0), SomeInt(10));
23     std::ranges::iota_view<SomeInt, SomeInt> io(commonView.begin(), commonView.end());
24     assert(std::ranges::next(io.begin(), 10) == io.end());
25   }
26 
27   {
28     std::ranges::iota_view unreachableSent(SomeInt(0));
29     std::ranges::iota_view<SomeInt> io(unreachableSent.begin(), std::unreachable_sentinel);
30     assert(std::ranges::next(io.begin(), 10) != io.end());
31   }
32 
33   {
34     std::ranges::iota_view differentTypes(SomeInt(0), IntComparableWith(SomeInt(10)));
35     std::ranges::iota_view<SomeInt, IntComparableWith<SomeInt>> io(differentTypes.begin(), differentTypes.end());
36     assert(std::ranges::next(io.begin(), 10) == io.end());
37   }
38 
39   return true;
40 }
41 
main(int,char **)42 int main(int, char**) {
43   test();
44   static_assert(test());
45 
46   return 0;
47 }
48 
49