iterator ambiguates rel_ops operators

Richard Andrews richarda@ixla.com.au
Wed Jan 17 16:32:00 GMT 2001


How can I use rel_ops and iterators together?

eg. try compiling this


#include <vector>

using std::rel_ops::operator!=;

class A
{
public:
    bool operator==(const A & rhs ) const { return true; }

};

bool compare( const A & lhs,
                const A & rhs )
{
	return (lhs!=rhs );
}

bool compare( const std::vector<int>::iterator & lhs,
                const std::vector<int>::iterator & rhs )
{
	return (lhs!=rhs );
}



There is a template operator!=() for __normal_iterator<T_> which ambiguates the rel_ops operator!=() making it impossible to use rel_ops anywhere near iterators.

How can I get around this problem? 
Is this a libstdc++ bug?





More information about the Libstdc++ mailing list