|
Boost Users : |
Subject: Re: [Boost-users] [ptr_container] Transferring the Last Element from a ptr_vector
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2009-09-09 14:19:16
2009/9/9 Steven Watanabe <watanabesj_at_[hidden]>:
>
> Scott McMurray wrote:
>>
>> 2009/9/9 Steven Watanabe <watanabesj_at_[hidden]>:
>>
>>>
>>> Nat Goodspeed wrote:
>>>
>>>>
>>>> Um -- I'm under the impression that decrementing the iterator returned
>>>> by
>>>> end() is discouraged. There are containers for which that definitely
>>>> would
>>>> not work.
>>>>
>>>
>>> It should work for any container that supports bidirectional iterators.
>>>
>>
>> ...except std::vector, iirc.
>
> The ability to decrement any bidirectional iterator
> except begin() is required by the standard. Â All Bidirectional
> iterators /must/ support this, including the iterators of
> std::vector. Â (See 24.1.4, Table 75)
>
Sorry, I didn't give enough context.
My understanding is that Nat was referring to using
"--container.end()" to get an iterator to the last element in a
container, which works for every bidi container but vector.
I see no reason why decrementing a normal lvalue iterator would be
"discouraged", as as you say, it's a fundamental bidi iterator
operation.
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