From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-05-07 09:45:41
Thorsten Ottosen wrote:
> "Peter Dimov" <pdimov_at_[hidden]> wrote in message
>> Thorsten Ottosen wrote:
>>> "Peter Dimov" <pdimov_at_[hidden]> wrote in message
>>>> Thorsten Ottosen wrote:
>>>> Range is begin(), end();
>>> So you want size() and empty() to be removed from the Range Traits?
>> I just omitted them for brevity, but since you ask, size() is
>> essential since it can be O(1) when distance( begin(), end() ) is
>> O(N), but it seems to me that empty() is always begin() == end(), so
>> it can be removed. (begin() and end() should be O(1).)
> hm...empty() is O(N) for strings if implemented as end() - begin(),
> but O(1) currently.
Yes, you are right, I missed that.
This however reminds me about a related issue. If I read the implementation
correctly, the size of T[N] is usually N, but it's N-1 when T is char or
wchar_t. I understand that this is being done to support "character
literals", but it obviously has the potential to introduce subtle off by one
bugs, especially in generic code.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk