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 // concept checking 12 // template<view V, class Pred> 13 // requires input_range<V> && is_object_v<Pred> && 14 // indirect_unary_predicate<const Pred, iterator_t<V>> 15 // class take_while_view; 16 17 #include <array> 18 #include <ranges> 19 20 #include "test_iterators.h" 21 22 template <class It> 23 using Range = std::ranges::subrange<It, sentinel_wrapper<It>>; 24 25 template <class Val = int> 26 struct Pred { 27 bool operator()(const Val&) const; 28 }; 29 30 template <class V, class Pred> 31 concept HasTakeWhileView = requires { typename std::ranges::take_while_view<V, Pred>; }; 32 33 static_assert(HasTakeWhileView<Range<int*>, bool (*)(int)>); 34 static_assert(HasTakeWhileView<Range<int*>, Pred<int>>); 35 36 // !view<V> 37 static_assert(!HasTakeWhileView<std::array<int, 5>, Pred<int>>); 38 39 // !input_range 40 static_assert(!HasTakeWhileView<Range<cpp20_output_iterator<int*>>, bool (*)(int)>); 41 42 // !is_object_v<Pred> 43 static_assert(!HasTakeWhileView<Range<int*>, Pred<int>&>); 44 45 // !indirect_unary_predicate<const Pred, iterator_t<V>> 46 static_assert(!HasTakeWhileView<Range<int*>, int>); 47 static_assert(!HasTakeWhileView<Range<int**>, Pred<int>>); 48