The following stripped-down code fails to compile in g++3.4.5 (compiles fine
with other compilers).

// CODE SNIPPET.
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

namespace MyNameSpace {
   struct Point
   {
      double x;
      double y;
      double z;
   };
} // namespace

std::ostream&
operator<< (std::ostream& os, const MyNameSpace::Point& src)
{
   return os;
}

int
main (void)
{
   std::vector<MyNameSpace::Point> polygons;

   copy (polygons.begin (), polygons.end (),
         std::ostream_iterator<MyNameSpace::Point> (std::cout, " ")); // ERROR

   return 0;
}

and g++ generates the following error message:

error: no match for 'operator<<' in
'*((std::ostream_iterator<MyNameSpace::Point, char, std::char_traits<char>
>*)this)->std::ostream_iterator<MyNameSpace::Point, char,
std::char_traits<char> >::_M_stream << __value'

Note: the code compiles if I removed the namespace.


-- 
           Summary: no match for 'operator<<'
           Product: gcc
           Version: 3.4.5
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tony dot luu at baesystems dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26037

Reply via email to