[C++-sig] Re: Adding __len__ to range objects

Joel de Guzman djowel at gmx.co.uk
Sat Sep 6 15:56:21 CEST 2003

Raoul Gough <RaoulGough at yahoo.co.uk> wrote:
> David Abrahams <dave at boost-consulting.com> writes:

>> Consider whether this might be a way to save on template
>> instantiations:
>>     slice_proxy
>>     {
>>         object c;
>>         object from;
>>         object to;
>>     };
>> Remember, the container is already wrapped into a runtime-polymorphic
>> object ;-)
> I already considered and had to reject an approach like this.
> Actually, I was thinking of using an iterator pair, but the problem
> would be the same. A slice on this basis will be in error as soon as
> an insertion or deletion occurs within the [from,to) range in the
> original container, since the value lookup is deferred until elements

No, of course not. slice_proxy shouldn't be that naive.
The slice_proxy can be thought of as:

        element_proxy from;
        element_proxy to;

The same element_proxy index management should apply to from and to.

Joel de Guzman

More information about the Cplusplus-sig mailing list