31#ifndef ETL_CLOSURE_INCLUDED
32#define ETL_CLOSURE_INCLUDED
48 template <
typename TSignature,
typename TCallback = etl::delegate<TSignature> >
51#if ETL_USING_CPP11 && !defined(ETL_CLOSURE_FORCE_CPP03_IMPLEMENTATION)
65 template <
typename TReturn,
typename... TArgs,
typename TCallback>
66 class closure<TReturn(TArgs...), TCallback>
73 using argument_types = etl::type_list<TArgs...>;
75 static_assert(etl::is_invocable_r<TReturn, TCallback, TArgs...>::value,
"Callback is not invocable with the specified arguments");
76 static_assert(etl::is_copy_constructible<TCallback>::value,
"Callback type must be copy constructible");
93 ETL_CONSTEXPR14 TReturn operator()()
const
95 return execute(etl::index_sequence_for<TArgs...>{});
105 template <
size_t Index,
typename UArg>
106 ETL_CONSTEXPR14
void bind(UArg arg)
108 static_assert(etl::is_convertible< UArg, etl::type_list_type_at_index_t<argument_types, Index>>::value,
"Argument is not convertible");
109 static_assert(!etl::is_reference<UArg>::value,
"Cannot bind reference arguments");
119 template <
typename... UArgs>
120 ETL_CONSTEXPR14
void bind(UArgs&&... args)
122 static_assert(
sizeof...(UArgs) ==
sizeof...(TArgs),
"Argument count mismatch");
123 bind_impl(etl::make_index_sequence<
sizeof...(TArgs)>{}, etl::forward<UArgs>(args)...);
132 template <
size_t... Indexes,
typename... UArgs>
133 ETL_CONSTEXPR14
void bind_impl(etl::index_sequence<Indexes...>, UArgs&&... args)
136 int dummy[] = {0, (bind<Indexes>(etl::forward<UArgs>(args)), 0)...};
145 template <
size_t... Indexes>
146 ETL_CONSTEXPR14 TReturn execute(etl::index_sequence<Indexes...>)
const
152 etl::tuple<TArgs...> m_args;
161 template <
typename TReturn,
typename TArg0,
typename TCallback>
202 template <
typename TReturn,
typename TArg0,
typename TArg1,
typename TCallback>
203 class closure<TReturn(TArg0, TArg1), TCallback>
207 typedef TCallback callback_type;
215 closure(
const callback_type& f,
const TArg0 arg0,
const TArg1 arg1)
228 return m_f(m_arg0, m_arg1);
246 template <
typename TReturn,
typename TArg0,
typename TArg1,
typename TArg2,
typename TCallback>
247 class closure<TReturn(TArg0, TArg1, TArg2), TCallback>
251 typedef TCallback callback_type;
260 closure(
const callback_type& f,
const TArg0 arg0,
const TArg1 arg1,
const TArg2 arg2)
274 return m_f(m_arg0, m_arg1, m_arg2);
294 template <
typename TReturn,
typename TArg0,
typename TArg1,
typename TArg2,
typename TArg3,
typename TCallback>
295 class closure<TReturn(TArg0, TArg1, TArg2, TArg3), TCallback>
299 typedef TCallback callback_type;
309 closure(
const callback_type& f,
const TArg0 arg0,
const TArg1 arg1,
const TArg2 arg2,
const TArg3 arg3)
324 return m_f(m_arg0, m_arg1, m_arg2, m_arg3);
346 template <
typename TReturn,
typename TArg0,
typename TArg1,
typename TArg2,
typename TArg3,
typename TArg4,
typename TCallback>
347 class closure<TReturn(TArg0, TArg1, TArg2, TArg3, TArg4), TCallback>
351 typedef TCallback callback_type;
362 closure(
const callback_type& f,
const TArg0 arg0,
const TArg1 arg1,
const TArg2 arg2,
const TArg3 arg3,
const TArg4 arg4)
378 return m_f(m_arg0, m_arg1, m_arg2, m_arg3, m_arg4);
closure(const callback_type &f, const TArg0 arg0, const TArg1 arg1, const TArg2 arg2, const TArg3 arg3, const TArg4 arg4)
Definition closure.h:362
TReturn operator()() const
Definition closure.h:376
TReturn operator()() const
Definition closure.h:322
closure(const callback_type &f, const TArg0 arg0, const TArg1 arg1, const TArg2 arg2, const TArg3 arg3)
Definition closure.h:309
TReturn operator()() const
Definition closure.h:272
closure(const callback_type &f, const TArg0 arg0, const TArg1 arg1, const TArg2 arg2)
Definition closure.h:260
TReturn operator()() const
Definition closure.h:226
closure(const callback_type &f, const TArg0 arg0, const TArg1 arg1)
Definition closure.h:215
closure(const callback_type &f, const TArg0 arg0)
Definition closure.h:174
TReturn operator()() const
Definition closure.h:184
TCallback callback_type
The callback type to be invoked.
Definition closure.h:167
T & get(array< T, Size > &a)
Definition array.h:1158
ETL_DEPRECATED_REASON("Misspelt class name") typedef scheduler_policy_sequential_single scheduler_policy_sequencial_single
Typedef for backwards compatibility with miss-spelt struct name.