[C++-sig] vector_indexing_suite issue

Joel de Guzman joel at boost-consulting.com
Tue Jan 27 01:23:07 CET 2004


Jeff Holle wrote:
> I am successfully using vector_indexing_suite in following code:
> 
>   class_<std::vector<B> >("vector_B")
>       .def(vector_indexing_suite<std::vector<B> >())
>       ;
> 
> However, I find that it requires that the B class conforms to the 
> Equality Comparable concept where the STL standard only demands it to 
> conform to the Assignable concept.
> 
> I'm wondering if this is necessary, and if so how the operator== method 
> should be coded.

The vector_indexing_suite attempts to encompass all Python methods
relevant to container types. See
http://www.python.org/doc/current/ref/sequence-types.html

This includes __contains__(self, item) which, of course, requires
that the container elements be equally comparable.

> Can it simply always return true or false?
> Or compare "this" pointers?

If you are not using the contains method or doing elemnt comparisons,
perhaps you can get by. However, this might cause confusion in the end
when someone does. << Caveat Emptor >>

Anyway, a nice thing about Raoul's new indexing suite is that each of
the methods can be turned on/off individually. This is not possible in
the original insexing_suite.

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






More information about the Cplusplus-sig mailing list