di 0.1.0
Loading...
Searching...
No Matches
stride.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace di::container::view {
7namespace detail {
8 struct StrideFunction;
9
10 template<typename Con, typename SSizeType>
11 concept CustomStride = concepts::TagInvocable<StrideFunction, Con, SSizeType>;
12
13 template<typename Con, typename SSizeType>
14 concept ViewStride = requires(Con&& container, SSizeType&& stride) {
15 StrideView { util::forward<Con>(container), util::forward<SSizeType>(stride) };
16 };
17
18 struct StrideFunction {
19 template<concepts::ViewableContainer Con, typename SSizeType = meta::ContainerSSizeType<Con>>
20 requires(CustomStride<Con, SSizeType> || ViewStride<Con, SSizeType>)
21 constexpr auto operator()(Con&& container, meta::TypeIdentity<SSizeType> stride) const -> concepts::View auto {
22 if constexpr (CustomStride<Con, SSizeType>) {
23 return function::tag_invoke(*this, util::forward<Con>(container), util::forward<SSizeType>(stride));
24 } else {
25 return StrideView { util::forward<Con>(container), util::forward<SSizeType>(stride) };
26 }
27 }
28 };
29}
30
31constexpr inline auto stride = function::curry_back(detail::StrideFunction {}, meta::c_<2ZU>);
32}
33
34namespace di {
35using view::stride;
36}
Definition adjacent.h:8
constexpr auto stride
Definition stride.h:31
StrideView(Con &&, meta::ContainerSSizeType< Con >) -> StrideView< meta::AsView< Con > >
constexpr tag_invoke_detail::TagInvokeFn tag_invoke
Definition tag_invoke.h:22
constexpr auto curry_back
Definition curry_back.h:141
Type< TypeConstant< T > > TypeIdentity
This is a helper template to prevent C++ from deducing the type of template argument.
Definition core.h:32
constexpr auto c_
A value of type Constexpr<val>.
Definition constexpr.h:252
Definition any_storable.h:9