From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2007-08-22 15:40:32
Howard Hinnant wrote:
> On Aug 22, 2007, at 2:37 PM, Emil Dotchevski wrote:
>>> Today I don't use list::size() in portable code. Why? Because we
>>> gave the vendor too much freedom.
>> How do you compute the size of a std::list in portable code then? :)
> I try not to. If I find I must, I write my own replacement list. It
> is one of the simpler containers to write.
I think that given a std::list object, the best way for user code to compute
its size is to call .size(). It would be a user error to assume that .size()
is O(1), but it wouldn't be a mistake to assume that the implementation of
size() will use the strategy that makes the most sense on that platform.
> Howard Hinnant wrote:
>> Vendor C, with the best of intentions, decides that the release build
>> of the std::lib should contain this checking (std::lib vendors
>> including debug checks in release builds should sound familiar to
>> many of you). Now we have goal #3, but have lost goal #1, and
>> there is no wrapper we can use to get it back.
We haven't lost goal #1. What has happened is that the vendor decided that
the benefits of supplying debug checks (goal #3) outweight the performance
cost of those checks, on that platform.
I don't see harm in that, as long as it doesn't violate the standard.
Consider that this decision was made by experts in the problem domain
targeting a specific platform.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk