Which comparision operator should be used inside std::find()?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



It is interesting: Does the C++ standard say explicitly which comparision
operator should be used inside the algorithm std::find or it is
implementation dependent?

For example I can write the find() using an inequality operator

template <typename InputIterator, typename T>

InputIterator find( InputIterator first, InputIterator last, const T
&value )
{
while ( ( first != last ) && ( *first != value ) ) ++ first;
return ( first );
}

Or I can write the same using an equality operator

template <typename InputIterator, typename T>

InputIterator find( InputIterator first, InputIterator last, const T
&value )
{
for ( ; first != last; ++ first )
{
if ( *first == value ) break;
}
return ( first );
}

Vladimir Grigoriev


.



Relevant Pages