di 0.1.0
Loading...
Searching...
No Matches
chunk_by.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 ChunkByFunction;
11
12 template<typename Con, typename Pred>
13 concept CustomChunkBy = concepts::TagInvocable<ChunkByFunction, Con, Pred>;
14
15 template<typename Con, typename Pred>
16 concept ViewChunkBy = requires(Con&& container, Pred&& predicate) {
17 ChunkByView { util::forward<Con>(container), util::forward<Pred>(predicate) };
18 };
19
20 struct ChunkByFunction {
21 template<concepts::ViewableContainer Con, typename Pred>
22 requires(CustomChunkBy<Con, Pred> || ViewChunkBy<Con, Pred>)
23 constexpr auto operator()(Con&& container, Pred&& predicate) const -> concepts::View auto {
24 if constexpr (CustomChunkBy<Con, Pred>) {
25 return function::tag_invoke(*this, util::forward<Con>(container), util::forward<Pred>(predicate));
26 } else {
27 return ChunkByView { util::forward<Con>(container), util::forward<Pred>(predicate) };
28 }
29 }
30 };
31}
32
33constexpr inline auto chunk_by = function::curry_back(detail::ChunkByFunction {}, meta::c_<2ZU>);
34}
35
36namespace di {
37using view::chunk_by;
38}
Definition adjacent.h:8
constexpr auto chunk_by
Definition chunk_by.h:33
ChunkByView(Con &&, Pred) -> ChunkByView< 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