g++ and -Weffc++ : why this warning for operator++() in nestedtemplate class?

Discussion in 'C++' started by wimalopaan, Aug 17, 2011.

  1. wimalopaan

    wimalopaan Guest

    Hi,

    in the following example

    template<typename T>
    class A {
    public:
    class B {
    public:
    B& operator++();
    };
    };

    template<typename T>
    typename A<T>::B& A<T>::B::eek:perator++() {
    return *this;
    }

    I get a warning


    In file included from cvl0001.cc:1:
    a.h:14: warning: prefix ‘typename A<T>::B& A<T>::B::eek:perator++()’
    should return ‘A<T>::B&’

    Well, if define the op++() inside the nested template class B, all is
    fine ...

    What's wrong here?

    --
    Wilhelm
     
    wimalopaan, Aug 17, 2011
    #1
    1. Advertising

  2. On 08/17/2011 09:40 AM, wimalopaan wrote:
    > Hi,
    >
    > in the following example
    >
    > template<typename T>
    > class A {
    > public:
    > class B {
    > public:
    > B& operator++();
    > };
    > };
    >
    > template<typename T>
    > typename A<T>::B& A<T>::B::eek:perator++() {
    > return *this;
    > }
    >
    > I get a warning
    >
    >
    > In file included from cvl0001.cc:1:
    > a.h:14: warning: prefix ‘typename A<T>::B& A<T>::B::eek:perator++()’
    > should return ‘A<T>::B&’
    >
    > Well, if define the op++() inside the nested template class B, all is
    > fine ...
    >
    > What's wrong here?


    got the same with g++ versions 4.3 and 4.4. versions 4.5 and 4.6 do not
    complain so it looks like old-g++ problem.

    --
    pozdrawiam serdecznie / best regards,
    Bartek 'BaSz' Szurgot

    http://www.baszerr.org
     
    bartek szurgot, Aug 17, 2011
    #2
    1. Advertising

  3. wimalopaan

    wimalopaan Guest

    Re: g++ and -Weffc++ : why this warning for operator++() in nestedtemplate class?

    On 17 Aug., 09:57, bartek szurgot <> wrote:
    > On 08/17/2011 09:40 AM, wimalopaan wrote:
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > > Hi,

    >
    > > in the following example

    >
    > > template<typename T>
    > > class A {
    > > public:
    > >     class B {
    > >     public:
    > >         B& operator++();
    > >     };
    > > };

    >
    > > template<typename T>
    > > typename A<T>::B& A<T>::B::eek:perator++() {
    > >     return *this;
    > > }

    >
    > > I get a warning

    >
    > > In file included from cvl0001.cc:1:
    > > a.h:14: warning: prefix ‘typename A<T>::B& A<T>::B::eek:perator++()’
    > > should return ‘A<T>::B&’

    >
    > > Well, if define the op++() inside the nested template class B, all is
    > > fine ...

    >
    > > What's wrong here?

    >
    > got the same with g++ versions 4.3 and 4.4. versions 4.5 and 4.6 do not
    > complain so it looks like old-g++ problem.
    >
    > --
    > pozdrawiam serdecznie / best regards,
    > Bartek 'BaSz' Szurgot
    >
    > http://www.baszerr.org


    Thanks for the hint: g++ 4.7 (svn) is ok too!
    --
    wilhelm
     
    wimalopaan, Aug 18, 2011
    #3
    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. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    912
    Mark Rae
    Dec 21, 2006
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,003
    Smokey Grindel
    Dec 2, 2006
  3. B. Williams

    warning C4267 and warning C4996

    B. Williams, Oct 26, 2006, in forum: C++
    Replies:
    17
    Views:
    2,635
  4. Replies:
    5
    Views:
    1,067
    red floyd
    Dec 3, 2009
  5. DeMarcus

    Is this a -Weffc++ bug in gcc?

    DeMarcus, Aug 16, 2012, in forum: C++
    Replies:
    9
    Views:
    506
    Tobias Müller
    Aug 17, 2012
Loading...

Share This Page