This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: unique_ptr and operator<<
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: papa at arbolone dot ca
- Cc: gcc-help Mailing List <gcc-help at gcc dot gnu dot org>
- Date: Mon, 6 Jul 2015 00:11:21 +0100
- Subject: Re: unique_ptr and operator<<
- Authentication-results: sourceware.org; auth=none
- References: <353594A937AA4515B8352B418E410102 at ArbolOneLT>
This is not a question about using GCC, please don't send such
questions to this list.
Please try a general C++ forum such as http://stackoverflow.com/
(The answer is that your code is not valid C++, you can't write a
unique_ptr to a stream, but I'm not going to explain how to fix it
because that's off-topic on this mailing list.)
On 5 July 2015 at 14:40, <papa@arbolone.ca> wrote:
> Can anyone, pleeese, tell me why this extractor operator is not causing this
> error:
> C:\tmp\adfs\main.cpp|20|error: no match for 'operator<<' (operand types are
> 'std::wostream {aka std::basic_ostream<wchar_t>}' and
> 'std::unique_ptr<jme::Name>')|
>
> namespace abc{
> class MyClass{
> private:
> int nuestro;
> public:
> MyClass(){}
> virtual MyClass(){}
> friend std::wostream& operator<<( std::wostream& os, const abc::Name& obj
> );
> };//class
>
> }//namespace abc
>
> cpp file
> ~~~~~~~~
> namespace abc{
> std::wostream& operator<<(abc::wostream& os, const abc::Name& obj) {
> return os << obj.getFirstName() << " "
> << obj.getMiddleName() << " "
> << obj.getLastName();
> }//operator<<
> } // namespace
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> http://www.avast.com
>