mirror of https://github.com/swig/swig
Bug 1498929: Access to member fields of map elements.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12643 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
11318bedff
commit
4b9ef9bc99
|
@ -4,6 +4,9 @@ See the RELEASENOTES file for a summary of changes in each release.
|
|||
|
||||
Version 2.0.4 (in progress)
|
||||
===========================
|
||||
2011-04-25: szager
|
||||
Fixed bug 1498929: Access to member fields in map elements
|
||||
|
||||
2011-04-23: klickverbot
|
||||
[D] nspace: Correctly generate identifiers for base classes when
|
||||
not in split proxy mode.
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
%module li_std_map_member
|
||||
|
||||
%inline %{
|
||||
int i;
|
||||
class TestA {
|
||||
public:
|
||||
TestA() { i = 1; }
|
||||
int i;
|
||||
};
|
||||
%}
|
||||
%include std_pair.i
|
||||
%include std_map.i
|
||||
|
||||
namespace std
|
||||
{
|
||||
%template(pairii) pair<int,int>;
|
||||
%template(mapii) map<int,int>;
|
||||
%template(pairita) pair<int,TestA>;
|
||||
%template(mapita) map<int,TestA>;
|
||||
}
|
|
@ -49,6 +49,7 @@ CPP_TEST_CASES += \
|
|||
li_implicit \
|
||||
li_std_vectora \
|
||||
li_std_vector_extra \
|
||||
li_std_map_member \
|
||||
li_std_multimap \
|
||||
li_std_pair_extra \
|
||||
li_std_set \
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
import li_std_map_member
|
||||
|
||||
a = li_std_map_member.mapita()
|
||||
a[1] = li_std_map_member.TestA()
|
||||
|
||||
if (a[1].i != 1) :
|
||||
raise RuntimeError("a[1] != 1")
|
||||
|
||||
a[1].i = 2
|
||||
if (a[1].i != 2) :
|
||||
raise RuntimeError("a[1] != 2")
|
|
@ -187,7 +187,7 @@
|
|||
#endif
|
||||
|
||||
%extend {
|
||||
mapped_type __getitem__(const key_type& key) const throw (std::out_of_range) {
|
||||
mapped_type const & __getitem__(const key_type& key) throw (std::out_of_range) {
|
||||
Map::const_iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
|
|
Loading…
Reference in New Issue