public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* template specializiation
@ 2005-07-07 13:42 Thomas Neumann
  2005-07-07 14:46 ` Eljay Love-Jensen
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Neumann @ 2005-07-07 13:42 UTC (permalink / raw)
  To: gcc-help

Hi,

I have a question concerning template specialization where gcc behaves 
different than other compilers. (I already asked this on 
comp.lang.c++.moderated, but got no response).

Is it possible to specialize just a member variable? (example code 
below). The C++ standard is a little bit vague on this or perhaps I just 
didn't get it. Existing C++ compilers seem to be undecided, gcc and 
Microsoft accept the sample code, while icc, Comeau and Borland reject it.

struct A {
     const A* a;
};

template <const char* c> struct B {
     static const A b;
};

extern const char c[1]="";
extern const char d[1]="";

template<> const A B<c>::b = {&B<d>::b};
template<> const A B<d>::b = {&B<c>::b};


I tend to think it is at least not allowed in this form (two
specialization referencing each other), at least icc gives a somewhat
convincing error message. Does anyone have an idea how to fix it? I want
to use template specialization to plug in information in a template
class, the different specializations need to reference each other. I do
not want to specialize the whole class, as most of it would be redundant.
Also I would like to add new specialization without changing header
files, which _seems_ to work using the approach shown above, but would
not work if I had to specialize the whole class.

Thomas

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-07-07 19:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-07 13:42 template specializiation Thomas Neumann
2005-07-07 14:46 ` Eljay Love-Jensen
2005-07-07 15:25   ` corey taylor
2005-07-07 15:51     ` Thomas Neumann
2005-07-07 15:56       ` corey taylor
     [not found]         ` <42CD567F.2090702@users.sourceforge.net>
2005-07-07 16:39           ` corey taylor
2005-07-07 19:34             ` Thomas Neumann
2005-07-07 16:39           ` corey taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).