C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Who is right on this C++ template example:

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Sven Rosvall
Guest





PostPosted: Sun Nov 30, 2003 1:35 am    Post subject: Who is right on this C++ template example: Reply with quote



Hi,
I got a piece of code that works with G++ but not with Intels C++
compiler (based on EDG). I have also tried it on Comeau's web site
where you can try the latest version.

template <typename T, T * Data, int Size>
class BoundedExternalArray
{};

template <class Array>
class BoundedPointerTraits
{};

template <typename T, T * Data, int Size>
class BoundedPointerTraits<BoundedExternalArray
{};

The error message is on "Data" in the parameter list of the partial
specialisation. The message is 'the type of partial specialization
template parameter constant "Data" depends on another template
parameter'. Looking in the standard, I find 14.5.4/9, bullet 2: "The
type of a template parameter corresponding to a specialized non-type
argument shall not be dependent on a parameter of the specialization."
I cannot really relate to this. "T" is not being specialised here,
"Array" is. Am I reading in the right place?

A collegue had a look at this and came up with another example:

template <typename T, T * t, typename S>
class A;

template <typename T, T * t>
class A<T, t, int> {};

Same result, GCC accepts this code and EDG does not (both Intel and
Comeau). In this case it is clear that "T" is not specialised.
Only "S" is specialised here.

So, please help me understand the standard. Are any of these two
examples legal? Or both?

Thanks for any help.
/ Sven--

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]

Back to top
Richard Corden
Guest





PostPosted: Tue Dec 02, 2003 6:44 pm    Post subject: Re: Who is right on this C++ template example: Reply with quote




Hi,

[email]sven-e (AT) lysator (DOT) liu.se[/email] (Sven Rosvall) writes:

<snip>

Quote:
template <typename T, T * t, typename S
class A;

template class A


For me, 14.5.4/9 is dependent on t being specialized. And if t is
considered specialized in the above example then I think that the
example should be illegal.

However, 14.5.4/8 says that "A non-type argument is non-specialized if
it is the name of a non-type parameter. All other non-type argu-ments
are specialized."

So, I think the above is legal and that G++ is right.

Cheers,

Richard



--
Richard Corden
To reply remove 's' from address

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.