On Sat, Feb 13, 2010 at 8:05 PM, Roman Yakovenko <roman.yakove...@gmail.com> wrote: > On Sat, Feb 13, 2010 at 5:41 PM, peoro <peoro.n...@gmail.com> wrote: >> Hello, >> I noticed that some Py++ traits for standard containers are missing a >> few methods that I think would be needed. >> For example `set_traits' (container traits for `std::set') is missing >> `method_len' that, in my opinion, should be provided. > > It is provided. > >> Is this a feature or a bug? And in the former case, how would I be >> supposed to get a set's size? explicitly exposing a `size' function >> for it? > > Did you try len( x )? >
Yes, I tried and it isn't working. This is the C++ code I'm trying to expose using Py++: #include <set> std::set<int> f( ) { return std::set<int>(); } Then, in python: >>> from set_len_test import * >>> x = f() >>> len( x ) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: object of type 'set_less__int__greater_' has no len() If I manually add `method_len' to `supported_methods' in `indexing_suite/set.hpp', and compile again the module, everything works as it should: >>> from set_len_len import * >>> x = f() >>> len( x ) 0 I've been trying with SVN revisions 1814 and 1824. > > -- > Roman Yakovenko > C++ Python language binding > http://www.language-binding.net/ > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig@python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig > _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig