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