0

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:
    SomeObject(/*Types ... args*/) /*: child(args...)*/
    {

    }
private:
    int num;        
};

The compiler (VS14 CTP 6) message just tells me:

syntax error: missing ',' before '<' in the line: class SomeObject: public Tpl<Ts...>
Fabian
  • 152
  • 2
  • 14

1 Answers1

1

The code is fine.

You didn't tell us what compiler (inc. its version) you're using, but presumably it has limited/no support for variadic templates or is buggy in this regard. Consider upgrading it or switching to something else entirely. GCC and Clang are both good.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055