Hi,
Firstly, great book (I've read both the 3rd and 4th editions cover to cover).
I have one question however regarding the Event Management System and its use of the Fast Delegate library.
It appears that you're using the Fast Delegate library as a way of calling member functions on objects.
If so then would it not be better to just use std::bind and std::function to do the same thing?
For example you could do the following:
typedef std::function<void (IEventDataPtr)> EventListenerDelegate;
Then in your EventManager you'd define the list as before:
typedef std::list<EventListenerDelegate> EventListenerList;
... and so on ...
Anything that calls VAddListener would construct the delegate parameter using std::bind, for example this:
EventListenerDelegate delegateFunc = MakeDelegate(this, &RoleSystem:: DestroyActorDelegate);
would become this:
EventListenerDelete delegateFunc = std::bind(&RoleSystem:: DestroyActorDelegate, this, _1);
I'm guessing that you didn't do this because this wasn't (Officially) supported until C++11?
Now that C++ does support this is there any reason why we should still use the FastDelegate library over the C++11 method?
Thanks
Ben
P.S. I'm guessing that with the 80+ hour weeks you're working at the moment that there's not much chance of a Fifth Edition of the book any time soon?
Firstly, great book (I've read both the 3rd and 4th editions cover to cover).
I have one question however regarding the Event Management System and its use of the Fast Delegate library.
It appears that you're using the Fast Delegate library as a way of calling member functions on objects.
If so then would it not be better to just use std::bind and std::function to do the same thing?
For example you could do the following:
typedef std::function<void (IEventDataPtr)> EventListenerDelegate;
Then in your EventManager you'd define the list as before:
typedef std::list<EventListenerDelegate> EventListenerList;
... and so on ...
Anything that calls VAddListener would construct the delegate parameter using std::bind, for example this:
EventListenerDelegate delegateFunc = MakeDelegate(this, &RoleSystem:: DestroyActorDelegate);
would become this:
EventListenerDelete delegateFunc = std::bind(&RoleSystem:: DestroyActorDelegate, this, _1);
I'm guessing that you didn't do this because this wasn't (Officially) supported until C++11?
Now that C++ does support this is there any reason why we should still use the FastDelegate library over the C++11 method?
Thanks
Ben
P.S. I'm guessing that with the 80+ hour weeks you're working at the moment that there's not much chance of a Fifth Edition of the book any time soon?
The post was edited 2 times, last by BenS1 ().