Skip to content

Commit 05d6717

Browse files
committed
Python builtin - add indexing support to std::set
1 parent 4715a4e commit 05d6717

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Examples/test-suite/python/li_std_set_runme.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
if i.next() != 3:
5555
raise RuntimeError
5656

57+
if si[0] != 1:
58+
raise RuntimeError
5759

5860
i = s.begin()
5961
i.next()

Lib/python/std_set.i

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@
3737
%swig_container_methods(set);
3838

3939
#if defined(SWIGPYTHON_BUILTIN)
40+
%feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__;
4041
%feature("python:slot", "sq_contains", functype="objobjproc") __contains__;
4142
#endif
4243

43-
%extend {
44+
%extend {
4445
void append(value_type x) {
4546
self->insert(x);
4647
}
@@ -60,8 +61,7 @@
6061
void discard(value_type x) {
6162
self->erase(x);
6263
}
63-
64-
};
64+
}
6565
%enddef
6666

6767
%include <std/std_set.i>

0 commit comments

Comments
 (0)