57 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// drop_while_view() requires default_initializable<V> && default_initializable<Pred> = default;12 13#include <cassert>14#include <ranges>15#include <type_traits>16 17template <bool DefaultInitializable>18struct View : std::ranges::view_base {19 int i = 42;20 constexpr explicit View()21 requires DefaultInitializable22 = default;23 int* begin() const;24 int* end() const;25};26 27template <bool DefaultInitializable>28struct Pred {29 int i = 42;30 constexpr explicit Pred()31 requires DefaultInitializable32 = default;33 bool operator()(int) const;34};35 36// clang-format off37static_assert( std::is_default_constructible_v<std::ranges::drop_while_view<View<true >, Pred<true >>>);38static_assert(!std::is_default_constructible_v<std::ranges::drop_while_view<View<false>, Pred<true >>>);39static_assert(!std::is_default_constructible_v<std::ranges::drop_while_view<View<true >, Pred<false>>>);40static_assert(!std::is_default_constructible_v<std::ranges::drop_while_view<View<false>, Pred<false>>>);41// clang-format on42 43constexpr bool test() {44 {45 std::ranges::drop_while_view<View<true>, Pred<true>> dwv = {};46 assert(dwv.base().i == 42);47 assert(dwv.pred().i == 42);48 }49 return true;50}51 52int main(int, char**) {53 test();54 static_assert(test());55 return 0;56}57