Instantiating a variadic member function template of a class template

折月煮酒 提交于 2019-12-11 07:11:32

问题


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.


回答1:


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).



来源:https://stackoverflow.com/questions/16691615/instantiating-a-variadic-member-function-template-of-a-class-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!