I am trying to speed up the compile time of the GLM(OpenGL Mathematics). GLM makes heavy usages 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 are using the glm::vec3
template, glm::vec3
is a typedef of glm::tvec3<float, glm::highp>
. The three files a,b,c
looks almost the same:
a.cpp, b.cpp, c.cpp
#include "math.h"
glm::vec3 func() {
glm::vec3 a = glm::vec3{1,1,1};
glm::vec3 b = glm::vec3{1,1,1};
return a + b;
}
I am using both explicit instantiation definition and explicit instantiation declaration. So the files a,b,c
should not cause implicit instantiation. But the compile time is the same as if I don´t do it.
Aucun commentaire:
Enregistrer un commentaire