di 0.1.0
Loading...
Searching...
No Matches
take_while.h
Go to the documentation of this file.
1#pragma once
2
6#include "di/util/forward.h"
7
8namespace di::container::view {
9namespace detail {
10 struct TakeWhileFunction;
11
12 template<typename Con, typename Pred>
13 concept CustomTakeWhile = concepts::TagInvocable<TakeWhileFunction, Con, Pred>;
14
15 template<typename Con, typename Pred>
16 concept ViewTakeWhile = requires(Con&& container, Pred&& predicate) {
17 TakeWhileView { util::forward<Con>(container), util::forward<Pred>(predicate) };
18 };
19
20 struct TakeWhileFunction {
21 template<concepts::ViewableContainer Con, typename Pred>
22 requires(CustomTakeWhile<Con, Pred> || ViewTakeWhile<Con, Pred>)
23 constexpr auto operator()(Con&& container, Pred&& predicate) const -> concepts::View auto {
24 if constexpr (CustomTakeWhile<Con, Pred>) {
25 return function::tag_invoke(*this, util::forward<Con>(container), util::forward<Pred>(predicate));
26 } else {
27 return TakeWhileView { util::forward<Con>(container), util::forward<Pred>(predicate) };
28 }
29 }
30 };
31}
32
33constexpr inline auto take_while = function::curry_back(detail::TakeWhileFunction {}, meta::c_<2ZU>);
34}
35
36namespace di {
37using view::take_while;
38}
Definition adjacent.h:8
constexpr auto take_while
Definition take_while.h:33
TakeWhileView(Con &&, Pred) -> TakeWhileView< meta::AsView< Con >, Pred >
constexpr tag_invoke_detail::TagInvokeFn tag_invoke
Definition tag_invoke.h:22
constexpr auto curry_back
Definition curry_back.h:141
constexpr auto c_
A value of type Constexpr<val>.
Definition constexpr.h:252
Definition any_storable.h:9