In pre-11 C ++, I had something like this:
template<class T,class U,class V>
struct Foo : T,U,V {
bool init() {
if(!T::init() || !U::init() || !V::init())
return false;
// do local init and return true/false
}
};
I would like to convert this to C ++ 11 variable syntax in order to take advantage of the flexible length argument list. I understand the concept of unpacking a list of arg templates using recursion, but I just can't figure out how the syntax is right. Here is what I tried:
template<typename... Features>
struct Foo : Features... {
template<typename F,typename... G>
bool recinit(F& arg,G&& ...args) {
if(!F::init())
return false;
return recinit<F,G...>(args...);
}
bool init() {
}
};
I would prefer that the order of calls to the base class functions init () remains left to right, but not critical.
source
share