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

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



Vladimir Grigoriev wrote:
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 );
}

==

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
.



Relevant Pages