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

Joel de Guzman djowel at gmx.co.uk
Mon Aug 25 15:26:27 CEST 2003


Raoul Gough <RaoulGough at yahoo.co.uk> wrote:
> "Joel de Guzman" <djowel at gmx.co.uk> writes:

> Well, my concern is to do with the complexity of the support - it
> seems to require hooks throughout all of the code that modifies the
> container. Maybe it would be possible to create a "container proxy"
> that emulates the vector interface, and use:
> 
> indexing_suite <container_proxy <std::vector<MyType> > >
> 
> Thus encapsulating the proxy code. I think this would localize the
> code much better, if it is possible to do.

A possibility, yes, nice idea.

> Another concern about this - have you considered cases where C++ code
> accesses the raw container (i.e. without going via the indexing
> suite)? e.g.
> 
>     val = c[i]
>     cxx_function(c)
>     val == c[i]  # ??
> 
> where cxx_function might (from C++) insert something into the
> container. If I understand correctly, doing an insertion via the
> indexing suite would notify the proxy when it needs to update its
> index. I think that means that raw C++ code that modifies the
> container would cause problems.

Yes, I am aware of that. That's a caveat. Before, the indexing_suite 
goes public, I have to provide a notification function that one needs 
to call in such cases. Right now, I am not sure about its interface.

> So what do you think of the idea of providing a proxy-container-
> wrapper, instead of integrating the proxy support directly into the
> indexing suite? C++ code would then be aware (and have direct access
> to) the wrapped container, and it might significantly simplify the
> internals of the indexing suite.

Looks like a good idea. Feel free to try it out. I'm all for further refactoring.

Cheers,
-- 
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net





More information about the Cplusplus-sig mailing list