48 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++14, c++1710 11// constexpr split_view() requires12// default_initializable<V> && default_initializable<Pattern> = default;13 14#include <cassert>15#include <ranges>16#include <type_traits>17 18template <bool DefaultInitializable>19struct View : std::ranges::view_base {20 int i = 42;21 constexpr explicit View()22 requires DefaultInitializable23 = default;24 int* begin() const;25 int* end() const;26};27 28// clang-format off29static_assert( std::is_default_constructible_v<std::ranges::split_view<View<true >, View<true >>>);30static_assert(!std::is_default_constructible_v<std::ranges::split_view<View<false>, View<true >>>);31static_assert(!std::is_default_constructible_v<std::ranges::split_view<View<true >, View<false>>>);32static_assert(!std::is_default_constructible_v<std::ranges::split_view<View<false>, View<false>>>);33// clang-format on34 35constexpr bool test() {36 {37 std::ranges::split_view<View<true>, View<true>> sv = {};38 assert(sv.base().i == 42);39 }40 return true;41}42 43int main(int, char**) {44 test();45 static_assert(test());46 return 0;47}48