Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-04-14 08:15:28

Gennaro Prota <gennaro_prota_at_[hidden]> writes:

> On Tue, 13 Apr 2004 15:08:35 +0200, "Pavel Vozenilek"
> <pavel_vozenilek_at_[hidden]> wrote:
>>"Gennaro Prota" <gennaro_prota_at_[hidden]> wrote
>>> Hmm. Here's an extremely condensed (not exhaustive) summary of
>>> changes, future directions and open issues.
>>Off topic:
> It isn't off topic, I guess :)
>> what is your opinion on being able to use
>>negative indexes in operator[]?
> Just for the case index == -1 or in general?

In general, this is a very useful idiom in Python. I'm not sure that
C++ should adopt it, though, because it imposes a speed penalty for
the normal case of indexing from the front (need to check for
negative numbers). You don't pay for what you don't use and all that.

>>Like bs[-1] would return the last value stored?
>>(Or with different syntax bs[boost.end - 1].)

That one is interesting because overload resolution can ensure that
there's no speed penalty.

Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at