#include <FXGenericTools.h>
Functors are a compile-time abstraction of some callable entity ie; basically an enhanced function or member function pointer. Their real usefulness comes in with binding whereby a functor can be bound with a set of arguments to form an arbitrary call to some API. This facility is used throughout TnFOX as a much improved form of callback plus within the dynamic linkage facilities. Up to four arbitrary parameters are currently supported (this is easily extended, just ask).
With any decent optimising compiler, the considerable complexity of the functor implementation boils down to two virtual method calls. Functor itself only occupies 4 + 8 bytes.
This functor operates with move semantics - a copy means destruction of the original. If you want a real copy, call copy(). You may find the helper function FX::Generic::BindFunctor of use when binding a functor's arguments.
Public Types | |
typedef FunctorHelper::ImplBaseOp < parslist, TL::length < parslist >::value-1 > | ImplBase |
typedef parslist | ParsList |
typedef ImplBase::R | R |
typedef ImplBase::P1 | P1 |
typedef ImplBase::P2 | P2 |
typedef ImplBase::P3 | P3 |
typedef ImplBase::P4 | P4 |
Public Member Functions | |
Functor () | |
template<typename fn> | |
Functor (fn fnptr) | |
template<typename obj, typename fn> | |
Functor (obj &objinst, fn fnptr) | |
template<typename obj, typename fn> | |
Functor (obj *objinst, fn fnptr) | |
Functor (void_ *fnptr) | |
Functor (ImplBase *_fnimpl) | |
Functor (Functor &o) | |
Functor & | operator= (Functor &o) |
Functor | copy () const |
bool | operator== (const Functor &o) const |
bool | operator!= (const Functor &o) const |
operator Tester * () const | |
bool | operator! () const |
R | operator() () |
R | operator() (P1 p1) |
R | operator() (P1 p1, P2 p2) |
R | operator() (P1 p1, P2 p2, P3 p3) |
R | operator() (P1 p1, P2 p2, P3 p3, P4 p4) |
FX::Generic::Functor< parslist >::Functor | ( | ) | [inline] |
Constructs a null functor.
Referenced by FX::Generic::Functor< FX::Generic::TL::create< long, FX::FXObject *, FXuint, void * >::value >::copy().
FX::Generic::Functor< parslist >::Functor | ( | fn | fnptr | ) | [inline, explicit] |
Constructs a functor calling a C-style function.
FX::Generic::Functor< parslist >::Functor | ( | obj & | objinst, | |
fn | fnptr | |||
) | [inline] |
Constructs a functor calling a member function of an object.
FX::Generic::Functor< parslist >::Functor | ( | obj * | objinst, | |
fn | fnptr | |||
) | [inline] |
Constructs a functor calling a member function of an object pointer.
FX::Generic::Functor< parslist >::Functor | ( | void_ * | fnptr | ) | [inline, explicit] |
Constructs a functor from a raw address calling a C-style function. This uses Functor::void_ *
to avoid the pointer consuming qualities of void *
FX::Generic::Functor< parslist >::Functor | ( | ImplBase * | _fnimpl | ) | [inline, explicit] |
Constructs a functor with a predefined implementation. Note: takes ownership of pointer.
Functor FX::Generic::Functor< parslist >::copy | ( | ) | const [inline] |
Returns a copy of this functor.
bool FX::Generic::Functor< parslist >::operator== | ( | const Functor< parslist > & | o | ) | const [inline] |
Compares two bound functors.
bool FX::Generic::Functor< parslist >::operator!= | ( | const Functor< parslist > & | o | ) | const [inline] |
Negation compares two bound functors.
R FX::Generic::Functor< parslist >::operator() | ( | ) | [inline] |
Calls what the functor points to.