|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-06-27 16:33:10
David Abrahams wrote:
> "Peter Dimov" <pdimov_at_[hidden]> writes:
>
>>> Yes. Why wouldn't you want this function to require that condition?
>>> Anything else is a coding error.
>>
>> I am reluctant to label it a coding error ("should never happen in a
>> correct program"), because in general it can be very hard to ensure
>> that the condition isn't violated. It's a bit like:
>>
>> Requires: a particular state of the library that you have no way of
>> querying.
>
> Harrumph. Isn't it the archive under construction whose state is
> constrained? If you know you've put 5 elements in a vector, you don't
> have to query it before calling pop_back(), do you?
So it's safe to remove size() and empty() from the vector interface as users
always know how large their vectors are, right?
If you are given a vector you don't know whether you can pop_back.
If you are given an archive you don't know whether you are allowed to save
by value, or whether you can safely save by pointer.
(In general.)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk