This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: The future C++ template model in gcc


> 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]