This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: The future C++ template model in gcc
Florian Schintke wrote:
> My idea is to not instantiate the templates,
> but to provide a generic template implementation that works
> for all template arguments.
In general this is not possible, consider (on an ILP=32 machine)
template <typename T> int Foo () {return sizeof (T);}
Foo<char> () // return 1
Foo<int> () // return 4
Foo<void *> () // return 4
Foo<char> must have a different instantiation than Foo<int> and Foo<void
*>,
but Foo<int> and Foo<void *> can have the same body. (This is what
you mean, right?)
Proving that the body can be shared like this, can be rather tricky.
The easiest solution might be have the linker remove copies by comparing
the bodies directly (or a fingerprint thereof).
nathan
--
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
Never hand someone a gun unless you are sure where they will point it
nathan@acm.org http://www.cs.bris.ac.uk/~nathan/ nathan@cs.bris.ac.uk