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'd like to convert this to C++11 variadic syntax to get the benefit of the flexible length argument list. I understand the concept of unpacking the template arg list using recursion but I just can't seen to get the syntax right. Here's what I've 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() {
// how to call recinit() from here?
}
};
I would prefer the order of the calls to the base class init() functions to be left-to-right but it's not critical.