From: Thomas Neumann <tneumann@users.sourceforge.net>
To: gcc-help@gcc.gnu.org
Subject: template specializiation
Date: Thu, 07 Jul 2005 13:42:00 -0000 [thread overview]
Message-ID: <42CD3120.5040906@users.sourceforge.net> (raw)
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
next reply other threads:[~2005-07-07 13:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-07 13:42 Thomas Neumann [this message]
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 16:39 ` corey taylor
2005-07-07 19:34 ` Thomas Neumann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42CD3120.5040906@users.sourceforge.net \
--to=tneumann@users.sourceforge.net \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).