Possible accept wrong code in C++?

Ed Smith-Rowland 3dw4rd@verizon.net
Wed Feb 22 01:14:00 GMT 2006


All,

I have a template class:

template < class Datum, unsigned long Dim >
class DataGrid
{
    ...
public:
    ...
    std::ostream &  write( std::ostream & output ) const;
    ...
};

I have a non-member operator overload:

On GCC-3.4 Cygwin I needed:

template < class Datum, unsigned long Dim >
inline std::ostream &  operator<<( std::ostream & output, const 
DataGrid<Datum,Dim> & data_grid )
{
    return  data_grid.write( output );
}

On GCC-4.0 MacOSX I was able to get by with this:

inline std::ostream &  operator<<( std::ostream & output, const DataGrid 
& data_grid )
{
    return  data_grid.write( output );
}

I actually think that 3.4 is right!!!
Am I wrong?

I'll try mainline and 4.1 when I get back home.

Ed Smith-Rowland



More information about the Gcc mailing list