I had the believe that the use of templates didn't affect performance.
That is, that from the performance point of view it's the same:
a)
template <class X>
class Y{
X attrib;
...
};
Y<int> myclass;
b)
class Y{
int attrib;
..
};
Y myclass;
However, some weeks ago I discovered that this is not exactly true, at
least for gcc 3.2. Specifically, I had one class of the type b) and I
wanted to converted to the type a) so as that the resulting X class
could have an attrib of any type and not only int. And then,
surprisingly for me, the program turned out to slow down considerably.
I took a look at some basic profiling data and I saw that now some
previously effectively inlined functions where not anymore... (and I
did'nt make any further modification in the code).
I would appreciate any help on this. I would like to know if this is a
limitation of the gcc 3.2 compiler, and then, if this is solved in 4.0
version, or it's a general limitation... and if there is some
workaround more elegant than using macros.
Thank you very much!
Leo.