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