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 | // constexpr iterator begin() const; |
12 | |
13 | #include <cassert> |
14 | #include <ranges> |
15 | #include <utility> |
16 | |
17 | #include "test_macros.h" |
18 | #include "types.h" |
19 | |
20 | template<class T> |
21 | constexpr void testType() { |
22 | { |
23 | std::ranges::iota_view<T> io(T(0)); |
24 | assert(*io.begin() == T(0)); |
25 | } |
26 | { |
27 | std::ranges::iota_view<T> io(T(10)); |
28 | assert(*io.begin() == T(10)); |
29 | assert(*std::move(io).begin() == T(10)); |
30 | } |
31 | { |
32 | const std::ranges::iota_view<T> io(T(0)); |
33 | assert(*io.begin() == T(0)); |
34 | } |
35 | { |
36 | const std::ranges::iota_view<T> io(T(10)); |
37 | assert(*io.begin() == T(10)); |
38 | } |
39 | } |
40 | |
41 | constexpr bool test() { |
42 | testType<SomeInt>(); |
43 | testType<long long>(); |
44 | testType<unsigned long long>(); |
45 | testType<signed long>(); |
46 | testType<unsigned long>(); |
47 | testType<int>(); |
48 | testType<unsigned>(); |
49 | testType<short>(); |
50 | testType<unsigned short>(); |
51 | |
52 | return true; |
53 | } |
54 | |
55 | int main(int, char**) { |
56 | test(); |
57 | static_assert(test()); |
58 | |
59 | return 0; |
60 | } |
61 | |