Python builtin C++11 STL fixes
Compilation fixes for std::multimap, std::unordered_map and std::unordered_multimap.
This commit is contained in:
parent
4ab2aff0a1
commit
b56d7c0539
3 changed files with 30 additions and 0 deletions
|
|
@ -68,7 +68,17 @@
|
||||||
|
|
||||||
%define %swig_multimap_methods(Type...)
|
%define %swig_multimap_methods(Type...)
|
||||||
%swig_map_common(Type);
|
%swig_map_common(Type);
|
||||||
|
|
||||||
|
#if defined(SWIGPYTHON_BUILTIN)
|
||||||
|
%feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__;
|
||||||
|
#endif
|
||||||
|
|
||||||
%extend {
|
%extend {
|
||||||
|
// This will be called through the mp_ass_subscript slot to delete an entry.
|
||||||
|
void __setitem__(const key_type& key) {
|
||||||
|
self->erase(key);
|
||||||
|
}
|
||||||
|
|
||||||
void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) {
|
void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) {
|
||||||
self->insert(Type::value_type(key,x));
|
self->insert(Type::value_type(key,x));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,17 @@
|
||||||
|
|
||||||
%define %swig_unordered_map_methods(Map...)
|
%define %swig_unordered_map_methods(Map...)
|
||||||
%swig_unordered_map_common(Map)
|
%swig_unordered_map_common(Map)
|
||||||
|
|
||||||
|
#if defined(SWIGPYTHON_BUILTIN)
|
||||||
|
%feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__;
|
||||||
|
#endif
|
||||||
|
|
||||||
%extend {
|
%extend {
|
||||||
|
// This will be called through the mp_ass_subscript slot to delete an entry.
|
||||||
|
void __setitem__(const key_type& key) {
|
||||||
|
self->erase(key);
|
||||||
|
}
|
||||||
|
|
||||||
void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) {
|
void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) {
|
||||||
(*self)[key] = x;
|
(*self)[key] = x;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,17 @@
|
||||||
|
|
||||||
%define %swig_unordered_multimap_methods(Type...)
|
%define %swig_unordered_multimap_methods(Type...)
|
||||||
%swig_unordered_map_common(Type);
|
%swig_unordered_map_common(Type);
|
||||||
|
|
||||||
|
#if defined(SWIGPYTHON_BUILTIN)
|
||||||
|
%feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__;
|
||||||
|
#endif
|
||||||
|
|
||||||
%extend {
|
%extend {
|
||||||
|
// This will be called through the mp_ass_subscript slot to delete an entry.
|
||||||
|
void __setitem__(const key_type& key) {
|
||||||
|
self->erase(key);
|
||||||
|
}
|
||||||
|
|
||||||
void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) {
|
void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) {
|
||||||
self->insert(Type::value_type(key,x));
|
self->insert(Type::value_type(key,x));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue