Re: Which comparision operator should be used inside std::find()?
- From: Victor Bazarov <v.Abazarov@xxxxxxxxxxxx>
- Date: Wed, 16 Dec 2009 08:03:38 -0500
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
.
- References:
- Which comparision operator should be used inside std::find()?
- From: Vladimir Grigoriev
- Which comparision operator should be used inside std::find()?
- Prev by Date: Re: Which comparision operator should be used inside std::find()?
- Next by Date: Re: Heap Corruption when using delete
- Previous by thread: Re: Which comparision operator should be used inside std::find()?
- Index(es):
Relevant Pages
|