This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Static data members in template declarations
- To: mark at markmitchell dot com
- Subject: Re: Static data members in template declarations
- From: Tim Hollebeek <tim at wagner dot princeton dot edu>
- Date: Tue, 3 Nov 1998 01:11:20 -0500 (EST)
- Cc: martin at mira dot isdn dot cs dot tu-berlin dot de, egcs at cygnus dot com
Mark Mitchell writes ...
>
> Your approach, however, would require that we cart around all
> declarations and definitions that have anything to do with a template
> class until instantiation time, and then merge/complain and otherwise
> analyze them then. Not only is this burdensome from an implementation
> point of view, it also does not seem, to me, to be what anyone
> intended w.r.t. templates. For example,
>
> template <class T>
> struct S {
> int f();
> };
>
> template <class T>
> T S<T>::f() {}
>
> You're proposing (at least by logical extension) that this is kosher
> as long as you only instantiate S with `int'. That seems peculiar.
And the logic for disallowing it is ... ? The language in the C++ standard
that forbids it is ... ?
The following code is also "peculiar":
template <class T>
struct S {
int *f() { return new T; }
};
but it certainly is legal C++, despite the fact that anything other than
S<int> is an error.
I fail to see how the error "return to `int *' from `double *'" is
fundamentally different from "new declaration `double S<double>::f()'
ambiguates old definition `int S<double>::f()'".
---------------------------------------------------------------------------
Tim Hollebeek | "Everything above is a true
email: tim@wfn-shop.princeton.edu | statement, for sufficiently
URL: http://wfn-shop.princeton.edu/~tim | false values of true."