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

51 lines
1015 B
C++

#ifndef ALSK_ALSK_SKELETON_MUSCLE_MUSCLE_H
#define ALSK_ALSK_SKELETON_MUSCLE_MUSCLE_H
#include <tmp/pack.h>
namespace alsk {
/**
* @brief hold the functionoid type and its links
*/
template<typename Type, typename Links>
using Fun = tmp::Pack<Type, Links>;
}
template<typename T, T> struct Fn;
template<typename R, typename... Ts, R(*F)(Ts...)>
struct Fn<R(*)(Ts...), F> {
using Signature = R(Ts...);
constexpr R operator()(Ts... args) { return F(args...); }
};
template<typename R, typename... Ts, R(&F)(Ts...)>
struct Fn<R(&)(Ts...), F> {
using Signature = R(Ts...);
constexpr R operator()(Ts... args) { return F(args...); }
};
#define FN(f) Fn<decltype(f)&, f>
#define FN_OVERLOAD(T, f) Fn<T, f>
/** C++17
* namespace impl {
*
* template<typename T, T> struct Fn;
*
* template<typename R, typename... Ts, R(*F)(Ts...)>
* struct Fn<R(*)(Ts...), F> {
* R operator()(Ts... args) { return F(args...); }
* };
*
* }
*
* template<auto F>
* using Fn = impl::Fn<decltype(F), F>;
*/
#endif