62 lines
1.7 KiB
C
62 lines
1.7 KiB
C
|
#ifndef ALSK_ALSK_SKELETON_BONE_ITERSEL_H
|
||
|
#define ALSK_ALSK_SKELETON_BONE_ITERSEL_H
|
||
|
|
||
|
#include "../bonebase.h"
|
||
|
|
||
|
namespace alsk {
|
||
|
|
||
|
template<typename, typename, typename> struct IterSel;
|
||
|
|
||
|
template<
|
||
|
typename Signature,
|
||
|
typename Task_, typename TaskLinks_,
|
||
|
typename Select_, typename SelectLinks_
|
||
|
>
|
||
|
struct IterSel<Signature, tmp::Pack<Task_, TaskLinks_>, tmp::Pack<Select_, SelectLinks_>>: SkeletonBase {
|
||
|
using Task = Task_;
|
||
|
using TaskLinks = TaskLinks_;
|
||
|
|
||
|
using Select = Select_;
|
||
|
using SelectLinks = SelectLinks_;
|
||
|
|
||
|
using Links = tmp::Pack<TaskLinks, SelectLinks>;
|
||
|
using PackP = tmp::Parameters<Signature>;
|
||
|
using PackR = Returns<Links>;
|
||
|
using PackX = tmp::Pack<>;
|
||
|
using Packs = arg::Placeholders<PackP, PackR, PackX>;
|
||
|
|
||
|
Task task;
|
||
|
Select select;
|
||
|
std::size_t n;
|
||
|
};
|
||
|
|
||
|
template<>
|
||
|
struct SkeletonTraits<IterSel> {
|
||
|
static constexpr bool serial = true;
|
||
|
|
||
|
template<typename Skeleton, typename F, typename T>
|
||
|
static constexpr decltype(auto) traverse(std::size_t parDepth, Skeleton&& skeleton, F&& function, T&& init) {
|
||
|
using TraverserTask = SkeletonTraversal<typename std::decay_t<Skeleton>::Task>;
|
||
|
using TraverserSelect = SkeletonTraversal<typename std::decay_t<Skeleton>::Select>;
|
||
|
return function(parDepth, skeleton,
|
||
|
TraverserTask::execute(parDepth, skeleton.task, function, std::forward<T>(init)),
|
||
|
TraverserSelect::execute(parDepth, skeleton.select, function, std::forward<T>(init))
|
||
|
);
|
||
|
}
|
||
|
|
||
|
template<typename Skeleton>
|
||
|
static constexpr std::size_t parallelizability(Skeleton&&) noexcept {
|
||
|
return 1;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
template<typename... Args, typename F>
|
||
|
void skeletonTraversal(IterSel<Args...> const& s, F f) {
|
||
|
f(s.task, 1);
|
||
|
f(s.select, 1);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif
|