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