1

I would like to have a function parameters of the template type of the variadic template class. How can the following code be well-formed?

template <typename T>
struct Foo {
  typedef T Base;
};

template <typename... Targs>
struct Bar {
  void get(Targs::Base... args) {} /// Type of the typedef Base of Foo!
};

int main() {
  Bar<Foo<int>, Foo<double>> bar;

  int i = 0;
  double j = 0.0;
  bar.get(i, j);
}

Using GCC 4.9 C++11 or 5.3.

Viatorus
  • 1,804
  • 1
  • 18
  • 41

1 Answers1

2

Easy. Watch my typename.

template <typename... Targs>
struct Bar {
  void get(typename Targs::Base... args) {} /// Type of the typedef Base of Foo!
};
SergeyA
  • 61,605
  • 5
  • 78
  • 137