I've seen people who have a template class declaration in a header file and the implementation in a .cpp file, and in the .cpp file they implement the methods, and then it appears they declare some template specifications for those functions, e.g., the below code does it:
Class declaration file:
template<int dim = 2>
struct custom_class {
void apply(int i, int j, int k);
}
Implementation file:
template <int dim>
void custom_class<dim>::apply() {
// implement apply
}
// what is the point of the below two lines?
template void custom_class<2>::apply(int i, int j, int k);
template void custom_class<3>::apply(int i, int j, int k);
I am wondering what is the point of the last 2 lines of this code? What does it do?