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 // template<class W, class Bound>
13 // requires (!is-integer-like<W> || !is-integer-like<Bound> ||
14 // (is-signed-integer-like<W> == is-signed-integer-like<Bound>))
15 // iota_view(W, Bound) -> iota_view<W, Bound>;
16
17 #include <ranges>
18 #include <cassert>
19 #include <concepts>
20
21 #include "test_macros.h"
22 #include "types.h"
23
24 template<class T, class U>
25 concept CanDeduce = requires(const T& t, const U& u) {
26 std::ranges::iota_view(t, u);
27 };
28
test()29 void test() {
30 static_assert(std::same_as<
31 decltype(std::ranges::iota_view(0, 0)),
32 std::ranges::iota_view<int, int>
33 >);
34
35 static_assert(std::same_as<
36 decltype(std::ranges::iota_view(0)),
37 std::ranges::iota_view<int, std::unreachable_sentinel_t>
38 >);
39
40 static_assert(std::same_as<
41 decltype(std::ranges::iota_view(0, std::unreachable_sentinel)),
42 std::ranges::iota_view<int, std::unreachable_sentinel_t>
43 >);
44
45 static_assert(std::same_as<
46 decltype(std::ranges::iota_view(0, IntComparableWith(0))),
47 std::ranges::iota_view<int, IntComparableWith<int>>
48 >);
49
50 static_assert( CanDeduce<int, int>);
51 static_assert(!CanDeduce<int, unsigned>);
52 static_assert(!CanDeduce<unsigned, int>);
53 }
54