samedi 28 février 2015

How to derive from a variadic template class in C++

I have variadic template class which is just a wrapper for std::tuple :



template <typename ... Child>
class Tpl
{
public:
Tpl() {}
Tpl(Child ...args) : child(args...)
{}

template <typename T>
T& Get()
{
return std::get<T>(child);
}

template <typename T>
const T& GetConst()
{
return std::get<T>(child);
}
private:
std::tuple<Child ...> child;
};


How do I correctly derive a class from Tpl?



template <typename... Ts>
class SomeObject : public Tpl<Ts...>
{
public:
Some(/*Types ... args*/) /*: child(args...)*/
{

}
private:
int num;
};


The compiler message just tells me: "syntax error: missing ',' before '<' in the line: class DbgGameObject : public Tpl


Thanks for your help!


Aucun commentaire:

Enregistrer un commentaire