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
- To: nathan at cs dot bris dot ac dot uk, schintke at zib dot de
- Subject: Re: The future C++ template model in gcc
- From: mike stump <mrs at windriver dot com>
- Date: Mon, 30 Jul 2001 09:19:00 -0700 (PDT)
- Cc: gcc at gcc dot gnu dot org, gdr at codesourcery dot com
> Date: Mon, 30 Jul 2001 10:22:35 +0100
> From: Nathan Sidwell <nathan@acm.org>
> In general this is not possible,
Sure it is.
> 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.
foo(type T) { return T.sizeof(); }
One body.
Don't give next the one that requires an overload decision, the code
would be just like the above, only more complex. In the end, it
devolves into a C++ interpreter.