显式模板实例化是放在 cpp 还是头文件中?
最佳答案
假设“显式模板实例化”是指类似
template class Foo<int>; // explicit type instantiation
// or
template void Foo<int>(); // explicit function instantiation
那么这些必须进入源文件,因为它们考虑了定义,因此受制于 ODR .
关于c++ - 显式模板实例化是否在 cpp 或头文件中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5864401/