public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Explicit specialization problem
@ 2004-11-26  6:20 Yogesh Kini
  2004-11-26  9:25 ` Nathan Sidwell
  0 siblings, 1 reply; 2+ messages in thread
From: Yogesh Kini @ 2004-11-26  6:20 UTC (permalink / raw)
  To: gcc-help

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 A, class B, class C>	
	class ABC
	{
		template<bool T>
		struct M
		{
			float a,b,c;		
		};
		
		template<>
		struct M<true>  -> Error here
		{
			int i,j,k;
		};
	};
	
};



main.cpp:59: error: enclosing class templates are not explicitly specialized
main.cpp:61: error: template parameters not used in partial specialization:
main.cpp:61: error:         `A'
main.cpp:61: error:         `B'
main.cpp:61: error:         `C'


___________________________________________________
Meet other people who share your interests.

http://www.homemaster.net - Homemaster. Come Together. Online.

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

* Re: Explicit specialization problem
  2004-11-26  6:20 Explicit specialization problem Yogesh Kini
@ 2004-11-26  9:25 ` Nathan Sidwell
  0 siblings, 0 replies; 2+ messages in thread
From: Nathan Sidwell @ 2004-11-26  9:25 UTC (permalink / raw)
  To: kini1982; +Cc: gcc-help

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 A, class B, class C>	
> 	class ABC
> 	{
> 		template<bool T>
> 		struct M
> 		{
> 			float a,b,c;		
> 		};
> 		
> 		template<>
> 		struct M<true>  -> 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<true> 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

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

end of thread, other threads:[~2004-11-26  9:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-26  6:20 Explicit specialization problem Yogesh Kini
2004-11-26  9:25 ` Nathan Sidwell

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).