diff options
author | Adrian Kummerlaender | 2021-05-17 00:30:13 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2021-05-17 00:30:13 +0200 |
commit | a92271176a19e06611099c0eccc4e6a6887f4915 (patch) | |
tree | 54067b334bfae7d99c79cfb00da5891334f9514c /src/operator.h | |
download | SweepLB-a92271176a19e06611099c0eccc4e6a6887f4915.tar SweepLB-a92271176a19e06611099c0eccc4e6a6887f4915.tar.gz SweepLB-a92271176a19e06611099c0eccc4e6a6887f4915.tar.bz2 SweepLB-a92271176a19e06611099c0eccc4e6a6887f4915.tar.lz SweepLB-a92271176a19e06611099c0eccc4e6a6887f4915.tar.xz SweepLB-a92271176a19e06611099c0eccc4e6a6887f4915.tar.zst SweepLB-a92271176a19e06611099c0eccc4e6a6887f4915.zip |
Extract public version of SweepLB
Diffstat (limited to 'src/operator.h')
-rw-r--r-- | src/operator.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/operator.h b/src/operator.h new file mode 100644 index 0000000..b4830eb --- /dev/null +++ b/src/operator.h @@ -0,0 +1,41 @@ +#pragma once + +#include <tuple> + +#include "concepts.h" + +namespace concepts { + +template <typename F, typename T, typename... ARGS> +concept Operator = Arithmetic<T> + && requires(F op, T* f_curr, T* f_next, ARGS... args) { + F::apply(f_curr, f_next, args...); +}; + +template <typename F, typename T> +concept Functor = Arithmetic<T> + && requires(F f, T* f_curr, T output[F::size]) { + F::observe(f_curr, output); +}; + +} + +template <typename F, typename M, typename... ARGS> +struct Operator { + M& mask; + std::tuple<ARGS...> args; + + Operator(F, M& m, ARGS&&... args): + mask(m), + args(std::forward<ARGS&&>(args)...) { } + + template <typename U> + requires concepts::Operator<F,U,ARGS...> + void operator()(U f_curr[], U f_next[]) { + std::apply([](auto... args) { F::apply(args...); }, + std::tuple_cat(std::make_tuple(f_curr, f_next), args)); + } +}; + +template <typename F, typename M, typename... ARGS> +Operator(F, M&, ARGS&&... args) -> Operator<F,M,ARGS...>; |