Debian Codegraph @

libcxx/test/std/ranges/range.factories/range.repeat.view/ctor.default.pass.cpp

raw
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 // repeat_view() requires default_initializable<T> = default;
12
13 #include <ranges>
14 #include <cassert>
15 #include <concepts>
16
17 struct DefaultInt42 {
18 int value = 42;
19 };
20
21 struct Int {
22 Int(int) {}
23 };
24
25 static_assert(std::default_initializable<std::ranges::repeat_view<DefaultInt42>>);
26 static_assert(!std::default_initializable<std::ranges::repeat_view<Int>>);
27
28 constexpr bool test() {
29 std::ranges::repeat_view<DefaultInt42> rv;
30 assert((*rv.begin()).value == 42);
31
32 return true;
33 }
34
35 int main(int, char**) {
36 test();
37 static_assert(test());
38
39 return 0;
40 }