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, c++20
10
11 // constexpr auto size() const requires (!same_as<Bound, unreachable_sentinel_t>);
12
13 #include <cassert>
14 #include <iterator>
15 #include <limits>
16 #include <ranges>
17
18 template <class T>
19 concept has_size = requires(T&& view) {
20 { std::forward<T>(view).size() };
21 };
22
23 static_assert(has_size<std::ranges::repeat_view<int, int>>);
24 static_assert(!has_size<std::ranges::repeat_view<int>>);
25 static_assert(!has_size<std::ranges::repeat_view<int, std::unreachable_sentinel_t>>);
26
test()27 constexpr bool test() {
28 {
29 std::ranges::repeat_view<int, int> rv(10, 20);
30 assert(rv.size() == 20);
31 }
32
33 {
34 constexpr int int_max = std::numeric_limits<int>::max();
35 std::ranges::repeat_view<int, int> rv(10, int_max);
36 assert(rv.size() == int_max);
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