A C++ template library for embedded applications
Designed and maintained by
Aster Consulting Ltd

function

A set of wrapper templates to allow a member or static function to be called without the caller having to know the specific
details of the callee apart from the parameter type. The templates allow the called function to be abstracted.

This may be used to implement a platform abstraction layer that allows an embedded application to interface with
multiple hardware platforms.

etl::function    Callbacks to free or member functions taking zero or one parameter. Function pointer at runtime.
etl::function_fv Callback to a free function taking no parameters. Function pointer at compile time.
etl::function_fp Callback to a free function taking one parameter. Function pointer at compile time.
etl::function_mv Callback to a member function taking no parameters. Function pointer at compile time.
etl::function_fp Callback to a member function taking one parameter. Function pointer at compile time.

See the tutorial.

Class definitions

template <typename TParameter>
class ifunction
Interface class for a function taking one parameter.

template <>
class ifunction<void>
Interface class for a function taking no parameters.

All of the following classes are derived from the above.

The following definitions are passed the function address at run time.

The functions are called indirectly through an internal pointer.

template <typename TObject, typename TParameter>
class function : public ifunction<TParameter>
Class for a member function taking one parameter.

template <typename TObject>
class function<TObject, void> : public ifunction<void>
Class for a member function taking no parameters.

template <typename TParameter>
class function<void, TParameter> : public ifunction<TParameter>
Class for a free function taking one parameter.

template <>
class function<void, void> : public ifunction<void>
Class for a free function taking no parameters.

The following definitions are passed the function address at compile time.

These will be more efficient than the previous definitions, as the one level of indirection is eliminated.

template <typename TObject, void (TObject::*Function)()>
class function_mv : public ifunction<void>
Class for a member function taking no parameters.

template <typename TObject, typename TParameter, void (TObject::*Function)(TParameter)>
class function_mp : public ifunction<TParameter>
Class for a member function taking one parameter.

template <void (*Function)()>
class function_fv : public ifunction<void>
Class for a free function taking no parameters.

template <typename TParameter, void (*Function)()>
class function_fp : public ifunction<TParameter>
Class for a free function taking one parameter.
function.h