#include <fwrap.hpp>
Public Member Functions | |
template<typename T> | |
fwrap (T fp) | |
fwrap () | |
fwrap (const fwrap &other) | |
void | swap (fwrap &other) |
fwrap & | operator= (fwrap rhs) |
bool | is_null () const |
val | operator() (fwrap_args &args) const |
Calls the underlying function. | |
unsigned int | arity () const |
Includes object instance for methods. | |
fwrap_fn_type | fn_type () const |
arg_info | get_rv_info () const |
void | get_arg_info (std::vector< arg_info > &vec) const |
For methods, type of first argument (object instance) will be pointer. | |
~fwrap () | |
Static Public Member Functions | |
template<typename ObjT, typename T> | |
static fwrap | wrap_ctor () |
Wrap a constructor. | |
Private Types | |
enum | ctor_overload_resolution { USE_PRIVATE_CONSTRUCTOR } |
Private Member Functions | |
fwrap (const detail::fwrap_store_base *store, const ctor_overload_resolution &) | |
Private Attributes | |
const detail::fwrap_store_base * | _store |
fwrap is not a template class. No matter what an fwrap instance wraps, it is called in the same way, by passing in a container (i.e. vector) of eval::val. Similarly, the return value of calling a wrapped function will always be an eval::val.
enum eval::fwrap::ctor_overload_resolution [private] |
eval::fwrap::fwrap | ( | T | fp | ) | [inline, explicit] |
Wrap a function or method.
fp
is a function or method pointer. eval::fwrap::fwrap | ( | ) | [inline] |
eval::fwrap::fwrap | ( | const fwrap & | other | ) | [inline] |
eval::fwrap::~fwrap | ( | ) | [inline] |
eval::fwrap::fwrap | ( | const detail::fwrap_store_base * | store, | |
const ctor_overload_resolution & | ||||
) | [inline, explicit, private] |
static fwrap eval::fwrap::wrap_ctor | ( | ) | [inline, static] |
Wrap a constructor.
The fwrap object returned is conceptually equivalent to a factory function. The return value from its invocation (an eval::val) assumes ownership of the actual created instance. ObjT
is the type of object the factory should create.
void (*)(Param1Type, Param2Type)
void eval::fwrap::swap | ( | fwrap & | other | ) | [inline] |
bool eval::fwrap::is_null | ( | ) | const [inline] |
val eval::fwrap::operator() | ( | fwrap_args & | args | ) | const [inline] |
Calls the underlying function.
An attempt is made to convert the objects in args
to the type required by the underlying function/method. Pass by value, reference or pointer are supported and handled implicitly. E.g. an eval::val may store a const int, in which case it could be used as a const int *, an int or a const int &, depending on what the underlying function requires. The val returned will assume ownership of the actual return value only if the underlying function returns by value. Otherwise, the val object will essentially use eval::UNMANAGED_PTR semantics. This may not be desirable if the function returns a pointer to one of its arguments for example (or a pointer generated using new).
null_ptr_exception | if is_null() | |
arity_mismatch_exception | if the number of arguments is wrong | |
bad_val_cast | if a conversion is not possible |
unsigned int eval::fwrap::arity | ( | ) | const [inline] |
Includes object instance for methods.
fwrap_fn_type eval::fwrap::fn_type | ( | ) | const [inline] |
arg_info eval::fwrap::get_rv_info | ( | ) | const [inline] |
void eval::fwrap::get_arg_info | ( | std::vector< arg_info > & | vec | ) | const [inline] |
For methods, type of first argument (object instance) will be pointer.
const detail::fwrap_store_base* eval::fwrap::_store [private] |