[C++-sig] Re: Adding __len__ to range objects
David Abrahams
dave at boost-consulting.com
Sat Sep 6 05:29:51 CEST 2003
"Joel de Guzman" <djowel at gmx.co.uk> writes:
>> Then again, it also wouldn't work if v[1:4] was a wrapped
>> vector<element_proxy>, so why not just use a real Python list and save
>> some template instantiation work. Actually, I'm not sure whether
>> creating a working vector<element_proxy> wrapper might not mean more
>> programming work for us as well, in which case I'm definitely against
>> it :-)
>
> I am considering a slice_proxy<Container>. I am not sure how complicated
> the implementation will be, but I think this is the right solution to the problem.
> Schematically:
>
> slice_proxy
> {
> Container& c;
> Index from;
> Index to;
> };
>
> As for the foo (v[1:4]) problem, you can have an implicit conversion from
> a slice_proxy<Container> to a Container.
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 ;-)
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list