Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > typedef of template<T> x to member x in template class

Reply
Thread Tools

typedef of template<T> x to member x in template class

 
 
squarewave@blockhead.net
Guest
Posts: n/a
 
      02-20-2009
Hi,

I was recently alerted by a user of an error reported by gcc 4.3.3,
when I typedef a previously defined template struct X as a member type with same name X
to remove the template parameters:

template<class T1, class T2, class T3>
struct Helper
{ /*...*/ };


template<class T1>
class MyClass
{
typedef Helper<T1, std::string, int> Helper; // gcc error
//typedef ::Helper ...etc would be accepted
};

gcc reports "error: changes meaning of 'Helper' from ..."

Questions:
- Is the gcc error correct? I guess so, but what's the relevant part of standard?
is Helper<T...> a dependent name, so covered by 14.6.2 - and Comeau's "pseudo-instantiation" doesn't get there...?)

- Is Comeau incorrect, or does the error arise in some later stage than provided by the online compiler?

Thanks for any help!


(I'd like to write C++, but tool support is dodgy.
- No MSVC version cuts it, so I run gcc 3.4 to get a second opinion,
and occasionally paste code and drop into Comeau online to get the sage view.
I'm a little worried if Comeau doesn't agree here, then I'm stumped.
I gather that gcc 4.x has not been ported to Windows)

Jocke



 
Reply With Quote
 
 
 
 
squarewave@blockhead.net
Guest
Posts: n/a
 
      02-20-2009
Ah. So now I found a clear verdict:
http://womble.decadentplace.org.uk/c...plate-faq.html
#7 "Two-phase lookup" and #10 "Which rules do the various C++ implementations apply..."


http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hi,
>
> I was recently alerted by a user of an error reported by gcc 4.3.3,
> when I typedef a previously defined template struct X as a member type
> with same name X
> to remove the template parameters:
>
> template<class T1, class T2, class T3>
> struct Helper
> { /*...*/ };
>
>
> template<class T1>
> class MyClass
> {
> typedef Helper<T1, std::string, int> Helper; // gcc error
> //typedef ::Helper ...etc would be accepted
> };
>
> gcc reports "error: changes meaning of 'Helper' from ..."
>
> Questions:
> - Is the gcc error correct? I guess so, but what's the relevant part of
> standard?
> is Helper<T...> a dependent name, so covered by 14.6.2 - and Comeau's
> "pseudo-instantiation" doesn't get there...?)
>
> - Is Comeau incorrect, or does the error arise in some later stage than
> provided by the online compiler?
>
> Thanks for any help!
>
>
> (I'd like to write C++, but tool support is dodgy.
> - No MSVC version cuts it, so I run gcc 3.4 to get a second opinion,
> and occasionally paste code and drop into Comeau online to get the sage
> view.
> I'm a little worried if Comeau doesn't agree here, then I'm stumped.
> I gather that gcc 4.x has not been ported to Windows)
>
> Jocke
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CRTP-problem: How can the base class typedef a derived class' typedef? oor C++ 0 05-20-2008 12:39 PM
parse error in gcc but success in vc.net, call a non_template class's template member function from a template class's member function! ken C++ 2 06-28-2005 06:57 AM
Template parameter (class) with a typedef member ThazKool C++ 7 05-11-2005 11:27 AM
typedef'd return type of a template class member function: take 2 Pete Becker C++ 5 11-19-2004 12:50 AM
typedef'd return type for a template class member function david.corby@gmail.com C++ 3 11-19-2004 12:10 AM



Advertisments