I'm trying to develop a simple C++11 Event/Delegate framework based on the The Impossibly Fast C++ Delegates, for my own use.
First, I wrote a delegate class with variadic template:
template<typename ReturnType, typename ... ParamTypes>
class Delegate
{
public:
template<typename T, void (T::*TMethod) (ParamTypes...)>
static inline Delegate from_method (T* object_ptr)
{
Delegate d;
// code to initialize members
return d;
}
// ... other code
Then I tried to write a template class to manage delegates:
template <typename ReturnType, typename ... ParamTypes>
class Event
{
public:
template<typename T>
void connect (T* obj, void (T::*TMethod) (ParamTypes...))
{
delegate_ = Delegate<ReturnType, PramTypes...>::from_method<T, TMethod>(obj);
// ^^^ compile error in this line
}
// ... other code
The intention of the function connect() is to pass "T" and "TMethod" to the static function of Delegate::from_method().
But the code block in connect() fails to be compiled.
Could anyone tell me what's wrong and how I should code correctly, I've googled and looked up in C++ books but cannot find the answer.
Thanks for your time and help!
Aucun commentaire:
Enregistrer un commentaire