Boost logo

Boost :

From: Greer, Joe (jgreer_at_[hidden])
Date: 2007-08-10 14:58:12

I'm going to jump in here because I am interested in this question as

> It's not the first time I've seen this, and I still do not understand
> what the belief of template meta-programming causing bloat is based

I think the general impression is that if I write a template class like:

template<typename T, size_t N>
class something

      a bunch of methods using m_arr

      T m_arr[N];

Then the code may well be generated for each kind of T the class is
instantiated for and possible for each kind of N as well. Now, I don't
know if compiler technology can combine all the code instances
automatically or not. I do know that you can rewrite it with a base
class such that the implementation is typesafe for the user, but "a
bunch of methods" won't be duplicated (depending upon what they are
anyway). Maybe you know. Can the compiler recognize something like the
above and only create one copy of the code in the class?


Boost list run by bdawes at, gregod at, cpdaniel at, john at