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 | // join_view() requires default_initializable<V> = default; |
12 | |
13 | #include <cassert> |
14 | #include <ranges> |
15 | |
16 | #include "types.h" |
17 | |
18 | struct DefaultView : std::ranges::view_base { |
19 | int i; // deliberately uninitialised |
20 | |
21 | ChildView* begin() const; |
22 | ChildView* end() const; |
23 | }; |
24 | |
25 | constexpr bool test() { |
26 | { |
27 | std::ranges::join_view<ParentView<ChildView>> jv; |
28 | assert(std::move(jv).base().ptr_ == globalChildren); |
29 | } |
30 | |
31 | // Default constructor should value initialise underlying view |
32 | { |
33 | std::ranges::join_view<DefaultView> jv; |
34 | assert(jv.base().i == 0); |
35 | } |
36 | |
37 | static_assert( std::default_initializable<std::ranges::join_view<ParentView<ChildView>>>); |
38 | static_assert(!std::default_initializable<std::ranges::join_view<CopyableParent>>); |
39 | |
40 | return true; |
41 | } |
42 | |
43 | int main(int, char**) { |
44 | test(); |
45 | static_assert(test()); |
46 | |
47 | return 0; |
48 | } |
49 | |