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