41class AIDelayedFunction;
77template<
typename R,
typename ...Args>
78class AIDelayedFunction<R(Args...)>
81 std::function<R(Args...)> m_function;
82 std::tuple<Args...> m_args;
96 { m_function = [object, memfn](Args... args){ (
object->*memfn)(args...); }; }
99 void swap(AIDelayedFunction& other)
noexcept
101 m_function.swap(other.m_function);
102 m_args.swap(other.m_args);
103 std::swap(m_result, other.m_result);
107 void operator()(Args... args) { m_args = std::make_tuple(args...); }
110 void invoke() { m_result = std::apply(m_function, m_args); }
113 R
const&
get()
const {
return m_result; }
117template<
typename ...Args>
118class AIDelayedFunction<void(Args...)>
121 std::function<void(Args...)> m_function;
122 std::tuple<Args...> m_args;
135 { m_function = [object, memfn](Args... args){ (
object->*memfn)(args...); }; }
138 void operator()(Args... args) { m_args = std::make_tuple(args...); }
141 void invoke() { std::apply(m_function, m_args); }
void operator()(Args... args)
Store the arguments to be passed.
Definition: AIDelayedFunction.h:107
void invoke()
Actually invoke the call to the stored function with the stored arguments.
Definition: AIDelayedFunction.h:110
AIDelayedFunction(R(*fp)(Args...))
Construct an AIDelayedFunction for a free function <span class="inlinecode">R f(Args....
Definition: AIDelayedFunction.h:87
R const & get() const
Get the result, only valid after invoke was called.
Definition: AIDelayedFunction.h:113
void swap(AIDelayedFunction &other) noexcept
Exchange the state with that of other.
Definition: AIDelayedFunction.h:99
AIDelayedFunction(C *object, R(C::*memfn)(Args...))
Definition: AIDelayedFunction.h:95
AIDelayedFunction(C *object, void(C::*memfn)(Args...))
Definition: AIDelayedFunction.h:134
void operator()(Args... args)
Store the arguments to be passed.
Definition: AIDelayedFunction.h:138
AIDelayedFunction(void(*fp)(Args...))
Construct a AIDelayedFunction for a free function.
Definition: AIDelayedFunction.h:126
void invoke()
Actually invoke the call to the stored function with the stored arguments.
Definition: AIDelayedFunction.h:141