Add explicit instantiations in the .cpp files, for very commonly used point types (while building pcl_registration).
When using ICP or TransformationEstimationSVD in other files, the extern template class ... statements in the .h files tell the compiler to not instantiate the templates, and to use the previous instantiations instead (from pcl_registration).
This decreases the compilation time for user code, and also for e.g. pcl tools and pcl apps (the pcl_icp tool for example compiles in 10s now vs 13s before).
The compilation time of PCL as a whole decreases slightly (1.5 percent less in one configuration with clang).
Supersedes and closes https://github.com/PointCloudLibrary/pcl/pull/5683
@themightyoarfish FYI. Feel free to test this.
So far, PCL offers explicit template instantiations for other classes in a different way: by hiding the complete template definition (which is in the .hpp files) when a user includes a .h file. Since the complete definition is not available, the compiler uses the existing instantiation from the PCL library (from the .cpp file).
This approach would not work for ICP and TransformationEstimationSVD because they both have three template parameters, and we would have to instantiate all possible parameter combinations in the .cpp file if we wanted to hide the template definition from the user. Otherwise we would risk that a user gets link errors when they use a template parameter combination not covered in the .cpp file.
By using the approach with extern template class ... in the .h files, the compiler still has the full template definition available (from the .hpp files, so it can instantiate it for any template parameter combination), but is told not to instantiate it for the three combinations that PCL offers already.
Add explicit instantiations in the .cpp files, for very commonly used point types (while building pcl_registration). When using ICP or TransformationEstimationSVD in other files, the
extern template class ...
statements in the .h files tell the compiler to not instantiate the templates, and to use the previous instantiations instead (from pcl_registration). This decreases the compilation time for user code, and also for e.g. pcl tools and pcl apps (the pcl_icp tool for example compiles in 10s now vs 13s before). The compilation time of PCL as a whole decreases slightly (1.5 percent less in one configuration with clang). Supersedes and closes https://github.com/PointCloudLibrary/pcl/pull/5683 @themightyoarfish FYI. Feel free to test this. So far, PCL offers explicit template instantiations for other classes in a different way: by hiding the complete template definition (which is in the .hpp files) when a user includes a .h file. Since the complete definition is not available, the compiler uses the existing instantiation from the PCL library (from the .cpp file). This approach would not work for ICP and TransformationEstimationSVD because they both have three template parameters, and we would have to instantiate all possible parameter combinations in the .cpp file if we wanted to hide the template definition from the user. Otherwise we would risk that a user gets link errors when they use a template parameter combination not covered in the .cpp file. By using the approach withextern template class ...
in the .h files, the compiler still has the full template definition available (from the .hpp files, so it can instantiate it for any template parameter combination), but is told not to instantiate it for the three combinations that PCL offers already.