|
Boost Users : |
From: David Rodríguez Ibeas (dibeas_at_[hidden])
Date: 2008-07-29 15:42:20
On Mon, Jul 28, 2008 at 7:01 PM, Steven Watanabe <watanabesj_at_[hidden]>wrote:
> AMDG
>
> Marshall Clow wrote:
>
>> At 12:00 AM -0500 7/27/08, Meryl Silverburgh wrote:
>>
>>> for (vector<A*>::const_iterator iter = aList.begin() ; iter !=
>>> aList.end(); ++iter) {
>>>
>>> A* anA = (*iter);
>>>
>>> // break out the for loop if aMethod return true;
>>> if (anA->aMethod()){
>>> break;
>>> }
>>>
>>
>> Isn't this what std::find_if does?
>>
>
> std::find_if is not quite equivalent to the for loop, because std::find_if
> is not allowed to modify the input sequence.
>
Ok, here's myquestion: What does exactly mean that std::find_if is not
allowed to change the sequence? How does the code. It is not changing the
vector in any way (just using a constant iterator) it is not even modifying
the contents of the vector. It is just calling a (possibly not constant)
method through a (constant) pointer. To me that is not modifying the input
sequence.
Or is it more a general concern that they are not equivalent even if in this
case std::find_if could be used?
David
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net