Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > g++ and -Weffc++ : why this warning for operator++() in nestedtemplate class?

Reply
Thread Tools

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

 
 
wimalopaan
Guest
Posts: n/a
 
      08-17-2011
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: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: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
 
Reply With Quote
 
 
 
 
bartek szurgot
Guest
Posts: n/a
 
      08-17-2011
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: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: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
 
Reply With Quote
 
 
 
 
wimalopaan
Guest
Posts: n/a
 
      08-18-2011
On 17 Aug., 09:57, bartek szurgot <no...@m.plz> 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: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: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
 
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
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
warning C4267 and warning C4996 B. Williams C++ 17 10-27-2006 09:41 PM
Warning: WARNING Charles Computer Support 7 08-16-2005 09:07 PM
Re: A code fix for MSVC warning C4267 (64-bit compatibility warning,e.g. Boost Spirit) Pete Becker C++ 0 02-10-2005 01:13 PM



Advertisments