c++: Why not allow in-class member template specialization?

Markus Werle numerical.simulation@web.de
Wed Jan 9 04:31:00 GMT 2002


Hi!

Though it is not a bug, but rather an open issue
(http://std.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html#44)
I would appreciate if future versions of g++ allowed in-class
specializations like this one:

struct A {
        template <int I> void f();
        template <> void f<0>();
    };

Some reasons:

* The reason for rejecting this is IMHO only due to an accident in formulation
that first was interpreted as if it were disallowed (namespace scope).

* From a user's point of view it's so logical to use it
it _must_ turned to be allowed, to keep the number of
C++ pitfalls low.

* In-Class specialization can always be achieved using
a helper template class containing the function.
So if we are able to  hack a workaround we also could
allow it directly: the brain damage is not for the compiler programmer,
only for the parser. And the C++ parser is brain damage anyway.
So let us put the brain damage where it belongs ;-)

* Intel C++ supports all of it without further complaint.
(since intel is willing to support C artifacts from gcc just to allow
linux kernel compilation with future compiler versions, gcc developers
could in turn support features they do not yet have)

* It is likely the feature will be supported in future standards.
Why not think about it today?


What do You think?
How hard is this feature to implement?


Markus



More information about the Gcc-bugs mailing list