Re: non template friend function and overloading

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2017.03.26 at 21:56 +0300, Shmuel Hanoch wrote:
> Hi,
> 
> I am trying to declare a (non template) friend function inside a template class.
> 
> This code compiles just fine:
> 
> #include <iostream>
> 
> template <class T>
> struct Foo;
> 
> template <class T>
> std::istream& operator>> (std::istream& is, Foo<T>& x);
> 
> template<class T>
> struct Foo
> {
>     //Foo operator>>(int x) const;
>     friend std::istream& operator>> <>(std::istream& is, Foo<T>& x);
> };
> 
> 
> But if I remove the comment from the other overload, I get this error message:
> 
> error: declaration of ‘operator>>’ as non-function
> 
> Is this overload illegal?

Sorry, but this is not the right place for general C++ questions.
(There is nothing gcc specific in it.)
Please use another forum like stackoverflow.

-- 
Markus



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux