1

How can I instantiate a variadic member function template of a class template in separate .cpp file? Say, given an above class template in a set of files: a.hpp with definition of interface, a_impl.hpp with implementation and a.cpp with instantiation, - which includes each previous in the chain sequentially, but only the first is visible to the user of the class (as opposed to the developer).

Especially interested in case of an empty parameter pack.

Tomilov Anatoliy
  • 15,657
  • 10
  • 64
  • 169

1 Answers1

2
template <class A>
struct AA
{
  template<class Z, class... Q>
  void aa(double, Q... q) {};
};

template void AA<int>::aa<char>(double);
template void AA<int>::aa<char, char*>(double, char*);
template void AA<int>::aa<char, char*, char**>(double, char*, char**);

Note that in your setup only the "developer" can instantiate (one needs to see the implementation in order to be able to instantiate).

n. m. could be an AI
  • 112,515
  • 14
  • 128
  • 243