51 #ifndef LIB_META_FUNCTION_H 52 #define LIB_META_FUNCTION_H 107 template<
typename FUN,
typename SEL =
void>
115 template<
typename FUN>
117 :
_Fun<decltype(&FUN::operator())>
123 template<
typename RET,
typename...ARGS>
129 using Sig = RET(ARGS...);
130 using Functor = std::function<Sig>;
131 enum { ARITY =
sizeof...(ARGS) };
135 template<
typename RET,
typename...ARGS>
136 struct _Fun<RET(ARGS...) noexcept>
141 template<
typename SIG>
147 template<
typename SIG>
153 template<
typename SIG>
159 template<
typename SIG>
165 template<
class C,
typename RET,
typename...ARGS>
166 struct _Fun<RET (C::*) (ARGS...)>
171 template<
class C,
typename RET,
typename...ARGS>
172 struct _Fun<RET (C::*) (ARGS...) noexcept>
179 template<
class C,
typename RET,
typename...ARGS>
180 struct _Fun<RET (C::*) (ARGS...) const>
185 template<
class C,
typename FUN>
195 template<
typename FUN>
199 template<
typename FUN>
202 static_assert(
_Fun<FUN>() ,
"something funktion-like required");
203 static_assert(
_Fun<FUN>::ARITY == 1 ,
"function with exactly one argument required");
211 template<
typename FUN>
212 using _FunArg =
typename _DetectSingleArgFunction<FUN>::Arg;
216 template<
typename FUN, u
int a>
217 using has_Arity = std::bool_constant<_Fun<FUN>::ARITY == a>;
219 template<
typename FUN>
220 using is_NullaryFun = has_Arity<FUN,0>;
222 template<
typename FUN>
223 using is_UnaryFun = has_Arity<FUN,1>;
225 template<
typename FUN>
226 using is_BinaryFun = has_Arity<FUN,2>;
240 template<
typename FUN,
typename SIG,
bool =_Fun<FUN>()>
242 : std::is_same<SIG, typename _Fun<FUN>::Sig>
246 template<
typename FUN,
typename X>
256 #define ASSERT_VALID_SIGNATURE(_FUN_, _SIG_) \ 257 static_assert (lib::meta::has_Sig<_FUN_, _SIG_>::value, \ 258 "Function " STRINGIFY(_FUN_) " unsuitable, expected signature: " STRINGIFY(_SIG_)); 270 template<
typename SIG,
typename FUN>
271 constexpr
inline auto 282 #define ASSERT_MEMBER_FUNCTOR(_EXPR_, _SIG_) \ 283 static_assert (lib::meta::isFunMember<_SIG_>(_EXPR_), \ 284 "Member " STRINGIFY(_EXPR_) " unsuitable, expect function signature: " STRINGIFY(_SIG_)); 300 template<
class W,
class TAR>
301 constexpr
inline TAR*
304 return static_cast<TAR*
> (&instance);
308 template<
class W,
typename X>
325 template<
class W,
class TUP>
326 constexpr
inline auto 329 auto splice = [&instance](
auto&& ...xs)
331 return std::tuple{
maybeInject (instance, std::move(xs))...};
333 return std::apply (splice, std::forward<TUP> (invocation));
349 template<
typename RET,
typename ARGS>
353 template<
typename RET>
356 using Sig = RET(
void);
358 using Func = function<Sig>;
359 using Functor = Func;
363 template<
typename RET
370 using Func = function<Sig>;
371 using Functor = Func;
375 template<
typename RET
381 using Sig = RET(A1,A2);
383 using Func = function<Sig>;
384 using Functor = Func;
388 template<
typename RET
395 using Sig = RET(A1,A2,A3);
397 using Func = function<Sig>;
398 using Functor = Func;
402 template<
typename RET
410 using Sig = RET(A1,A2,A3,A4);
412 using Func = function<Sig>;
413 using Functor = Func;
417 template<
typename RET
426 using Sig = RET(A1,A2,A3,A4,A5);
428 using Func = function<Sig>;
429 using Functor = Func;
433 template<
typename RET
443 using Sig = RET(A1,A2,A3,A4,A5,A6);
445 using Func = function<Sig>;
446 using Functor = Func;
450 template<
typename RET
461 using Sig = RET(A1,A2,A3,A4,A5,A6,A7);
463 using Func = function<Sig>;
464 using Functor = Func;
468 template<
typename RET
480 using Sig = RET(A1,A2,A3,A4,A5,A6,A7,A8);
482 using Func = function<Sig>;
483 using Functor = Func;
487 template<
typename RET
500 using Sig = RET(A1,A2,A3,A4,A5,A6,A7,A8,A9);
502 using Func = function<Sig>;
503 using Functor = Func;
constexpr auto lateBindInstance(W &instance, TUP &&invocation)
Fix-up the arguments for a member-function invocation, allowing to inject the actual this instance in...
A template metaprogramming technique for manipulating collections of types.
constexpr auto isFunMember(FUN)
Helper to pick up a member field for verification.
Implementation namespace for support and library code.
typename _DetectSingleArgFunction< FUN >::Arg _FunArg
abbreviation for referring to a function's single Argument type
typename _Fun< FUN >::Ret _FunRet
abbreviation for referring to a function's return type