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

Discussion in 'C++' started by squarewave@blockhead.net, Feb 20, 2009.

  1. Guest

    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
    , Feb 20, 2009
    #1
    1. Advertising

  2. Guest

    Ah. So now I found a clear verdict:
    http://womble.decadentplace.org.uk/c /template-faq.html
    #7 "Two-phase lookup" and #10 "Which rules do the various C++ implementations apply..."


    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
    >
    >
    >
    , Feb 20, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. E11
    Replies:
    1
    Views:
    4,737
    Thomas Weidenfeller
    Oct 12, 2005
  2. Replies:
    3
    Views:
    463
    Victor Bazarov
    Nov 19, 2004
  3. Pete Becker
    Replies:
    5
    Views:
    1,012
    =?iso-8859-1?Q?Ali_=C7ehreli?=
    Nov 19, 2004
  4. ThazKool
    Replies:
    7
    Views:
    480
    Matthias Kaeppler
    May 11, 2005
  5. oor
    Replies:
    0
    Views:
    1,343
Loading...

Share This Page