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<
class C,
typename RET,
typename...ARGS>
160 struct _Fun<RET (C::*) (ARGS...)>
165 template<
class C,
typename RET,
typename...ARGS>
166 struct _Fun<RET (C::*) (ARGS...) noexcept>
173 template<
class C,
typename RET,
typename...ARGS>
174 struct _Fun<RET (C::*) (ARGS...) const>
179 template<
class C,
typename FUN>
196 template<
typename FUN,
typename SIG,
bool =_Fun<FUN>()>
198 : std::is_same<SIG, typename _Fun<FUN>::Sig>
202 template<
typename FUN,
typename X>
212 #define ASSERT_VALID_SIGNATURE(_FUN_, _SIG_) \ 213 static_assert (lib::meta::has_Sig<_FUN_, _SIG_>::value, \ 214 "Function " STRINGIFY(_FUN_) " unsuitable, expected signature: " STRINGIFY(_SIG_)); 226 template<
typename SIG,
typename FUN>
227 constexpr
inline auto 238 #define ASSERT_MEMBER_FUNCTOR(_EXPR_, _SIG_) \ 239 static_assert (lib::meta::isFunMember<_SIG_>(_EXPR_), \ 240 "Member " STRINGIFY(_EXPR_) " unsuitable, expect function signature: " STRINGIFY(_SIG_)); 256 template<
class W,
class TAR>
257 constexpr
inline TAR*
260 return static_cast<TAR*
> (&instance);
264 template<
class W,
typename X>
281 template<
class W,
class TUP>
282 constexpr
inline auto 285 auto splice = [&instance](
auto&& ...xs)
287 return std::tuple{
maybeInject (instance, std::move(xs))...};
289 return std::apply (splice, std::forward<TUP> (invocation));
305 template<
typename RET,
typename ARGS>
309 template<
typename RET>
312 typedef function<RET(void)> Func;
317 template<
typename RET
322 typedef function<RET(A1)> Func;
327 template<
typename RET
333 typedef function<RET(A1,A2)> Func;
334 typedef RET Sig(A1,A2);
338 template<
typename RET
345 typedef function<RET(A1,A2,A3)> Func;
346 typedef RET Sig(A1,A2,A3);
350 template<
typename RET
358 typedef function<RET(A1,A2,A3,A4)> Func;
359 typedef RET Sig(A1,A2,A3,A4);
363 template<
typename RET
372 typedef function<RET(A1,A2,A3,A4,A5)> Func;
373 typedef RET Sig(A1,A2,A3,A4,A5);
377 template<
typename RET
387 typedef function<RET(A1,A2,A3,A4,A5,A6)> Func;
388 typedef RET Sig(A1,A2,A3,A4,A5,A6);
392 template<
typename RET
403 typedef function<RET(A1,A2,A3,A4,A5,A6,A7)> Func;
404 typedef RET Sig(A1,A2,A3,A4,A5,A6,A7);
408 template<
typename RET
420 typedef function<RET(A1,A2,A3,A4,A5,A6,A7,A8)> Func;
421 typedef RET Sig(A1,A2,A3,A4,A5,A6,A7,A8);
425 template<
typename RET
438 typedef function<RET(A1,A2,A3,A4,A5,A6,A7,A8,A9)> Func;
439 typedef RET Sig(A1,A2,A3,A4,A5,A6,A7,A8,A9);
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.