I was wondering whether you should worry about the number of class template instantiations and their effect on compile times. In the below example, I imagined that the Foo template would only be instantiated only once, while the Bar template would be instantiated twice. Do such differences matter to STL writers?
template<unsigned SIZE>
struct Foo
{
const unsigned size_;
Foo() : size_(SIZE) {}
};
Foo<1> foo1;
Foo<2> foo2;
template<unsigned SIZE>
struct Bar
{
static constexpr unsigned size_{SIZE};
};
Bar<1> bar1;
Bar<2> bar2;
I'm feeling like I'm wrong about the Foo template being instantiated only once. If so could you tell me whether
Bar<1> bar1;
Bar<1> bar2
...
Bar<1> bar10000;
would instantiate the Bar template once or 10,000 times.
Class templates instantiate types, types instantiate objects, does reducing the number for instantiated types matter if the number of objects instantiated remain the same?
Are such things even relevant to compile times (I doubt they would be for my purposes)