I am trying to speed up GLM compilation time (OpenGL math). GLM makes heavy use of C ++ templates.
This is what I have tried so far.
math.h #pragma once #include <glm\glm.hpp> extern template struct glm::tvec3<float, glm::highp>;
math.cpp #include "math.h" template struct glm::tvec3<float, glm::highp>;
And then I have three files that use the glm::vec3 , glm::vec3 is the typedef from glm::tvec3<float, glm::highp> . The three files a,b,c look almost the same:
a.cpp, b.cpp, c.cpp
I use both an explicit definition of instantiation and a declaration of explicit instantiation. Therefore, files a,b,c should not cause implicit instantiation. But the compilation time is the same as if I did not.
c ++ c ++ 11 templates extern
hidayat
source share