rcolyer.net
RC Lib  Version 201607061602
Public Member Functions | List of all members
RC::Caller< Ret, Params > Class Template Reference

A general purpose function class which can refer to any static method, member method, functor, or lambda function. More...

#include <Caller.h>

Inheritance diagram for RC::Caller< Ret, Params >:
RC::UntypedCaller

Public Member Functions

 Caller ()
 Default constructor, refers to no function.
 
 Caller (const Caller &other)
 Copy constructor.
 
template<class C >
 Caller (C *object, Ret(C::*func)(Params...))
 Construct a Caller to a member function of a specific object.
 
template<class C >
 Caller (C &object, Ret(C::*func)(Params...))
 Construct a Caller to a member function of a specific object.
 
template<class C , class... OneFewerParams>
 Caller (Ret(C::*func)(OneFewerParams...))
 Construct a Caller to a member function, where the inserted first parameter is a reference to the object. More...
 
template<class Functor >
 Caller (Functor func)
 Construct a Caller to any general functor. More...
 
virtual ~Caller ()
 Destructor.
 
Calleroperator= (const Caller< Ret, Params... > &other)
 Assign a Caller of identical type.
 
virtual Ret operator() (Params...params) const
 Call the referenced function.
 
bool IsSet ()
 True if a function was set.
 
template<class TupleType >
Ret Use (TupleType tup)
 Call the referenced function with the parameters given as RC::Tuple tup.
 
template<class... Args>
auto Bind (Args...args) -> decltype(std::bind(*this, args...))
 Return a functor with arguments bound using syntax identical to std::bind. More...
 

Detailed Description

template<class Ret, class... Params>
class RC::Caller< Ret, Params >

A general purpose function class which can refer to any static method, member method, functor, or lambda function.

Template parameters are specified as the return type followed by a list of the argument types. If access is attempted on an undefined Caller, ErrorMsgNull is thrown. If a member method Caller is constructed with the object as the first parameter, then the call is assigned to that object, which can be used for passing handlers. The convenience functions MakeCaller and MakeFunctor can be used for automatic type inference. Strict compile time type-checking is performed upon assignment or construction. To explicitly wrap with loose type-checking, use MakeFunctor on a Caller.

Constructor & Destructor Documentation

template<class Ret, class... Params>
template<class C , class... OneFewerParams>
RC::Caller< Ret, Params >::Caller ( Ret(C::*)(OneFewerParams...)  func)
inline

Construct a Caller to a member function, where the inserted first parameter is a reference to the object.

Usage example: class A { void F(int x) {} }; Caller<void, A&, int> c(&A::F); c(5);

template<class Ret, class... Params>
template<class Functor >
RC::Caller< Ret, Params >::Caller ( Functor  func)
inline

Construct a Caller to any general functor.

Note, for a Caller functor of a slightly different type, use MakeFunctor to avoid the intentional type-checking compile error.

Member Function Documentation

template<class Ret, class... Params>
template<class... Args>
auto RC::Caller< Ret, Params >::Bind ( Args...  args) -> decltype(std::bind(*this, args...))
inline

Return a functor with arguments bound using syntax identical to std::bind.

The return type of this is an unspecified functor, but it can be wrapped in a MakeFunctor with the corresponding types.


The documentation for this class was generated from the following file:
email address
— (c) 2015