Which comparision operator should be used inside std::find()?
- From: "Vladimir Grigoriev" <vlad.moscow@xxxxxxx>
- Date: Wed, 16 Dec 2009 15:38:23 +0300
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
.
- Follow-Ups:
- Re: Which comparision operator should be used inside std::find()?
- From: Victor Bazarov
- Re: Which comparision operator should be used inside std::find()?
- From: Igor Tandetnik
- Re: Which comparision operator should be used inside std::find()?
- Prev by Date: Re: Heap Corruption when using delete
- Next by Date: Re: Heap Corruption when using delete
- Previous by thread: Heap Corruption when using delete
- Next by thread: Re: Which comparision operator should be used inside std::find()?
- Index(es):
Relevant Pages
|