42 #ifndef LIB_META_FUNCTION_H 43 #define LIB_META_FUNCTION_H 98 template<
typename FUN,
typename SEL =
void>
106 template<
typename FUN>
108 :
_Fun<decltype(&FUN::operator())>
114 template<
typename RET,
typename...ARGS>
120 using Sig = RET(ARGS...);
121 using Functor = std::function<Sig>;
122 enum { ARITY =
sizeof...(ARGS) };
126 template<
typename RET,
typename...ARGS>
127 struct _Fun<RET(ARGS...) noexcept>
132 template<
typename SIG>
138 template<
typename SIG>
144 template<
typename SIG>
150 template<
typename SIG>
156 template<
class C,
typename RET,
typename...ARGS>
157 struct _Fun<RET (C::*) (ARGS...)>
162 template<
class C,
typename RET,
typename...ARGS>
163 struct _Fun<RET (C::*) (ARGS...) noexcept>
170 template<
class C,
typename RET,
typename...ARGS>
171 struct _Fun<RET (C::*) (ARGS...) const>
176 template<
class C,
typename FUN>
186 template<
typename FUN>
190 template<
typename FUN>
193 static_assert(
_Fun<FUN>() ,
"something funktion-like required");
194 static_assert(
_Fun<FUN>::ARITY == 1 ,
"function with exactly one argument required");
202 template<
typename FUN>
203 using _FunArg =
typename _DetectSingleArgFunction<FUN>::Arg;
207 template<
typename FUN, u
int a>
208 using has_Arity = std::bool_constant<_Fun<FUN>::ARITY == a>;
210 template<
typename FUN>
211 using is_NullaryFun = has_Arity<FUN,0>;
213 template<
typename FUN>
214 using is_UnaryFun = has_Arity<FUN,1>;
216 template<
typename FUN>
217 using is_BinaryFun = has_Arity<FUN,2>;
231 template<
typename FUN,
typename SIG,
bool =_Fun<FUN>()>
233 : std::is_same<SIG, typename _Fun<FUN>::Sig>
237 template<
typename FUN,
typename X>
247 #define ASSERT_VALID_SIGNATURE(_FUN_, _SIG_) \ 248 static_assert (lib::meta::has_Sig<_FUN_, _SIG_>::value, \ 249 "Function " STRINGIFY(_FUN_) " unsuitable, expected signature: " STRINGIFY(_SIG_)); 261 template<
typename SIG,
typename FUN>
262 constexpr
inline auto 273 #define ASSERT_MEMBER_FUNCTOR(_EXPR_, _SIG_) \ 274 static_assert (lib::meta::isFunMember<_SIG_>(_EXPR_), \ 275 "Member " STRINGIFY(_EXPR_) " unsuitable, expect function signature: " STRINGIFY(_SIG_)); 291 template<
class W,
class TAR>
292 constexpr
inline TAR*
295 return static_cast<TAR*
> (&instance);
299 template<
class W,
typename X>
316 template<
class W,
class TUP>
317 constexpr
inline auto 320 auto splice = [&instance](
auto&& ...xs)
322 return std::tuple{
maybeInject (instance, std::move(xs))...};
324 return std::apply (splice, std::forward<TUP> (invocation));
340 template<
typename RET,
typename ARGS>
344 template<
typename RET>
347 using Sig = RET(
void);
349 using Func = function<Sig>;
350 using Functor = Func;
354 template<
typename RET
361 using Func = function<Sig>;
362 using Functor = Func;
366 template<
typename RET
372 using Sig = RET(A1,A2);
374 using Func = function<Sig>;
375 using Functor = Func;
379 template<
typename RET
386 using Sig = RET(A1,A2,A3);
388 using Func = function<Sig>;
389 using Functor = Func;
393 template<
typename RET
401 using Sig = RET(A1,A2,A3,A4);
403 using Func = function<Sig>;
404 using Functor = Func;
408 template<
typename RET
417 using Sig = RET(A1,A2,A3,A4,A5);
419 using Func = function<Sig>;
420 using Functor = Func;
424 template<
typename RET
434 using Sig = RET(A1,A2,A3,A4,A5,A6);
436 using Func = function<Sig>;
437 using Functor = Func;
441 template<
typename RET
452 using Sig = RET(A1,A2,A3,A4,A5,A6,A7);
454 using Func = function<Sig>;
455 using Functor = Func;
459 template<
typename RET
471 using Sig = RET(A1,A2,A3,A4,A5,A6,A7,A8);
473 using Func = function<Sig>;
474 using Functor = Func;
478 template<
typename RET
491 using Sig = RET(A1,A2,A3,A4,A5,A6,A7,A8,A9);
493 using Func = function<Sig>;
494 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