From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10379 invoked by alias); 26 Nov 2004 09:25:33 -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 10332 invoked from network); 26 Nov 2004 09:25:26 -0000 Received: from unknown (HELO mail2.codesourcery.com) (66.160.135.55) by sourceware.org with SMTP; 26 Nov 2004 09:25:26 -0000 Received: (qmail 11697 invoked from network); 26 Nov 2004 09:25:26 -0000 Received: from admin.voldemort.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.9) by mail2.codesourcery.com with SMTP; 26 Nov 2004 09:25:26 -0000 Received: (qmail 9851 invoked from network); 26 Nov 2004 09:25:25 -0000 Received: from localhost (HELO ?192.168.189.167?) (nathan@127.0.0.1) by mail.codesourcery.com with SMTP; 26 Nov 2004 09:25:25 -0000 Message-ID: <41A6F67E.7040501@codesourcery.com> Date: Fri, 26 Nov 2004 09:25:00 -0000 From: Nathan Sidwell Organization: Codesourcery LLC User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913 MIME-Version: 1.0 To: kini1982@postmaster.co.uk CC: gcc-help@gcc.gnu.org Subject: Re: Explicit specialization problem References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-11/txt/msg00188.txt.bz2 Yogesh Kini wrote: > Hi, > When I compile the below code using gcc 3.3 I get the errors as below. > But MS VC++ compiles it straight. Can any one please tell me what the problem is? > > Thanks, > Yogesh > > namespace xyz > { > template > class ABC > { > template > struct M > { > float a,b,c; > }; > > template<> > struct M -> Error here > { > int i,j,k; > }; > }; > > }; This is ill-formed. For two reasons 1) [14.7.3]/2 says an explicit specialization of a member template shall be declared in the namespace of the enclosing class. I.e. you have to move the M specialization out. 2) [14.7.3]/18 says that an explicit specialization of a member class template of a templated class must also specialize the outer class. I.e. you cannot put a specialized class inside a non-specialized class. nathan -- Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk