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 //  lazy_split_view() requires default_initializable<V> && default_initializable<P> = default;
13 
14 #include <ranges>
15 
16 #include <cassert>
17 #include "types.h"
18 
19 struct ThrowingDefaultCtorForwardView : std::ranges::view_base {
20   ThrowingDefaultCtorForwardView() noexcept(false);
21   forward_iterator<int*> begin() const;
22   forward_iterator<int*> end() const;
23 };
24 
25 struct NoDefaultCtorForwardView : std::ranges::view_base {
26   NoDefaultCtorForwardView() = delete;
27   forward_iterator<int*> begin() const;
28   forward_iterator<int*> end() const;
29 };
30 
31 static_assert( std::is_default_constructible_v<std::ranges::lazy_split_view<ForwardView, ForwardView>>);
32 static_assert(!std::is_default_constructible_v<std::ranges::lazy_split_view<NoDefaultCtorForwardView, ForwardView>>);
33 static_assert(!std::is_default_constructible_v<std::ranges::lazy_split_view<ForwardView, NoDefaultCtorForwardView>>);
34 
35 static_assert( std::is_nothrow_default_constructible_v<std::ranges::lazy_split_view<ForwardView, ForwardView>>);
36 static_assert(!std::is_nothrow_default_constructible_v<ThrowingDefaultCtorForwardView>);
37 static_assert(!std::is_nothrow_default_constructible_v<
38     std::ranges::lazy_split_view<ThrowingDefaultCtorForwardView, ForwardView>>);
39 
test()40 constexpr bool test() {
41   {
42     std::ranges::lazy_split_view<CopyableView, ForwardView> v;
43     assert(v.base() == CopyableView());
44   }
45 
46   {
47     std::ranges::lazy_split_view<CopyableView, ForwardView> v = {};
48     assert(v.base() == CopyableView());
49   }
50 
51   return true;
52 }
53 
main(int,char **)54 int main(int, char**) {
55   test();
56   static_assert(test());
57 
58   return 0;
59 }
60