Python builtin - add indexing support to std::unordered_set

This commit is contained in:
William S Fulton 2018-09-21 19:30:31 +01:00
commit 146998ce81
2 changed files with 3 additions and 0 deletions

View file

@ -38,6 +38,7 @@ for x in [cpp11_hash_tables.SetInt([1]),
cpp11_hash_tables.UnorderedMultiSetInt([1])]:
swig_assert_equal([e for e in x], [1])
swig_assert_equal(x[0], 1)
swig_assert_equal(1 in x, True)
swig_assert_equal(2 in x, False)

View file

@ -45,8 +45,10 @@
#if defined(SWIGPYTHON_BUILTIN)
%feature("python:slot", "sq_contains", functype="objobjproc") __contains__;
%feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__;
#endif
%extend {
void append(value_type x) {
self->insert(x);