I have a object subclassed from Parent
that creates a child. It gives the child an std::function
to call to report status, but in practice the std:function
would probably always be a method on the parent, so as a convenience an additional constructor is provided that takes that as an argument.
I've made a typedef
of the std::function
, but I can't figure out how to make a typedef
of the method pointer.
class Child { // No Hungarian: abstract class, so no variables of this type exist.
public:
typedef std::function< void( Parent* pparent_in, Msg* pmsg ) > FuncCB;
// can't figure out some way to define an MethodCB.
//template<T> typedef void (T::*MethodCB)();
Child( Parent* pparent_in, FuncCB asynccb_in ) :
pparent( pparent_in ),
asynccb_( asynccb_in )
{
};
template<typename T>
// can't figure out some way to define an MethodCB.
//Child( Parent* pparent_in, MethodCB pmethod_in ) :
Child( Parent* pparent_in, void (T::*pmethod_in)() ) :
Child( pparent_in, [=]() { (pparent_in->*pmethod_in)(); } )
{
};
Aucun commentaire:
Enregistrer un commentaire