2012/11/8 Brian Budge <brian.budge@gmail.com>
Hi all -I have a case where I have a largeish inheritance hierarchy. I will be calling an initialization function on all objects before using them in some fashion.Basically what I need to happen is when I call init() on a Foo the following would occur:void Foo::init() {super::init();// now with the knowledge that anything I inherited is set up, I can set myself up...}It is not necessary for every call to implement init, in which case the behavior should be that the call is propagated up the inheritance chain (which it is by default in C++).In order to make this work, I need to write different code for "super" in every class implementation, which is a bit error prone. Even if I don't copy/paste, my brain might be on autopilot and type something further up the inheritance chain than it should be. Alternatively, I could require that each class provides a typedef for super, but I'm still relying on myself to remember to call super's init function.Is there anything in boost that would support this kind of hierarchy traversal (semi-)automatically? If there is not, are there suggestions for ways to implement this in a less error-prone fashion?Thanks,Brian