Are there any language lawyers in the house?
Should the following code compile?
include <set> bool fn( const std::set<int>& rSet ) { if ( rSet.find( 42 ) != rSet.end() ) return true; return false; }
On one of the platforms (Sun Workshop) this does not compile. It reports that the find function returned an iterator and the end function that returned a const_iterator and that it does not have a valid comparison operator between those types.
The following does compile:
include <set> bool fn( std::set<int>& rSet ) { if ( rSet.find( 42 ) != rSet.end() ) return true; return false; }
It should compile. Set includes 2 find() functions and 2 end() functions (const and non-const versions). It sort of sounds like Sun’s STL is broken somehow. Since you are passing in a const reference, the compiler should be able to select the correct find() and end() functions.