Skip to content

Commit 146998c

Browse files
committed
Python builtin - add indexing support to std::unordered_set
1 parent 05d6717 commit 146998c

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

Examples/test-suite/python/cpp11_hash_tables_runme.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def swig_assert_equal(a, b):
3838
cpp11_hash_tables.UnorderedMultiSetInt([1])]:
3939

4040
swig_assert_equal([e for e in x], [1])
41+
swig_assert_equal(x[0], 1)
4142

4243
swig_assert_equal(1 in x, True)
4344
swig_assert_equal(2 in x, False)

Lib/python/std_unordered_set.i

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@
4545

4646
#if defined(SWIGPYTHON_BUILTIN)
4747
%feature("python:slot", "sq_contains", functype="objobjproc") __contains__;
48+
%feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__;
4849
#endif
4950

51+
5052
%extend {
5153
void append(value_type x) {
5254
self->insert(x);

0 commit comments

Comments
 (0)