rosa/inc/alsk/skeleton/muscle/muscle.h

51 lines
1015 B
C
Raw Permalink Normal View History

2021-05-10 16:14:24 +00:00
#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