I\'m compiling a C++ library which defines a single function that randomly samples from a set of data points. The data points are stored in a std::vector
. There a
I believe the long time relates to vector being a template. The compiler needs to rewrite every occurance of push_back
with the corresponding function. It's like having many overloaded functions, where the compile needs to do name mangling to address the correct function. This is an extra work compared to simply compiling non-overloaded functions.