From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11995 invoked by alias); 7 Jul 2005 13:42:37 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 11985 invoked by uid 22791); 7 Jul 2005 13:42:33 -0000 Received: from pm1.terions.de (HELO pm1.terions.de) (83.137.96.25) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 07 Jul 2005 13:42:33 +0000 Received: (qmail 15417 invoked by uid 1007); 7 Jul 2005 13:42:22 -0000 Received: from 139.19.54.43 by prmx.terions.de (envelope-from , uid 98) with qmail-scanner-1.24 (f-prot: 4.3.2/3.14.7. spamassassin: 3.0.1. Clear:RC:0(139.19.54.43):. Processed in 0.091687 secs); 07 Jul 2005 13:42:22 -0000 X-Spam-Scanner-Mail-From: tneumann@users.sourceforge.net via prmx.terions.de X-Spam-Scanner: 1.24 (Clear:RC:0(139.19.54.43):. Processed in 0.091687 secs) Received: from mpino5503.ag5.mpi-sb.mpg.de (HELO ?139.19.54.43?) (tn@tneumann.de@139.19.54.43) by mail.s-s-l.net with SMTP; 7 Jul 2005 13:42:21 -0000 Message-ID: <42CD3120.5040906@users.sourceforge.net> Date: Thu, 07 Jul 2005 13:42:00 -0000 From: Thomas Neumann User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) MIME-Version: 1.0 To: gcc-help@gcc.gnu.org Subject: template specializiation Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2005-07/txt/msg00074.txt.bz2 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 struct B { static const A b; }; extern const char c[1]=""; extern const char d[1]=""; template<> const A B::b = {&B::b}; template<> const A B::b = {&B::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