rosa/inc/alsk/skeleton/bone/while.h
2021-05-10 18:14:24 +02:00

64 lines
1.7 KiB
C++

#ifndef ALSK_ALSK_SKELETON_BONE_WHILE_H
#define ALSK_ALSK_SKELETON_BONE_WHILE_H
#include "../bonebase.h"
namespace alsk {
template<typename, typename, typename> struct While;
template<
typename Signature,
typename Test_, typename TestLinks_,
typename Task_, typename TaskLinks_
>
struct While<Signature, tmp::Pack<Test_, TestLinks_>, tmp::Pack<Task_, TaskLinks_>>: SkeletonBase {
using Test = Test_;
using TestLinks = TestLinks_;
using Task = Task_;
using TaskLinks = TaskLinks_;
using Links = tmp::Pack<TestLinks_, TaskLinks_>;
using PackP = tmp::Parameters<Signature>;
using PackR = Returns<Links>;
using PackX = tmp::Pack<>;
using Packs = arg::Placeholders<PackP, PackR, PackX>;
Test test;
Task task;
~While() noexcept {}; // -Winline
};
template<>
struct SkeletonTraits<While> {
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 TraverserTest = SkeletonTraversal<typename std::decay_t<Skeleton>::Test>;
using TraverserTask = SkeletonTraversal<typename std::decay_t<Skeleton>::Task>;
return function(parDepth,
skeleton,
TraverserTest::execute(parDepth, skeleton.task, function, std::forward<T>(init)),
TraverserTask::execute(parDepth, skeleton.task, 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(While<Args...> const& s, F f) {
f(s.test, 1);
f(s.task, 1);
}
}
#endif