I am writing a C++ library in which I use functions that take as parameters expression templates in Eigen3. Basically the definitions of my functions are similar to
template <typename T>
/* return type */ f(Eigen::MatrixBase<T> param)
{
// function body
}
The input parameter looks a bit strange at a first sight, but what it really does is that it allows to use expression templates. For example, I can use the function like
f(A * B + C * D * F)
The type of the above argument is some very-very-long-to-spell-here template type (an expression template), and not a plain matrix. Such expression templates allow for speed optimizations etc, so I really need to use them.
Now comes my question:
I have quite a few of these functions, and whenever I instantiate them with different expressions, the compiler generates an instantiation at compile time, hence the compiling time becomes a bit larger. In my case, it's still quite ok, around 30 seconds on an i5 8GB RAM, however I'd very much like to reduce the compilation time. Is there any way or any tricks I can use to somehow reduce the compiling time but still to be able to use expression templates?