add test for std::vector<A*>
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5839 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b83d738529
commit
f9d781feee
2 changed files with 19 additions and 5 deletions
|
|
@ -58,14 +58,19 @@ void halve_in_place(std::vector<double>& v) {
|
||||||
namespace Test {
|
namespace Test {
|
||||||
struct A {
|
struct A {
|
||||||
virtual ~A() {}
|
virtual ~A() {}
|
||||||
virtual void f(const int i) const = 0;
|
virtual int f(const int i) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct B : public A {
|
struct B : public A {
|
||||||
void f(const int i) const
|
int val;
|
||||||
{ std::cout << "B::f(int)\n"; }
|
|
||||||
|
B(int i = 0) : val(i)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int f(const int i) const { return i + val; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
%template(VecB) std::vector<Test::B>; // works
|
%template(VecB) std::vector<Test::B>;
|
||||||
%template(VecA) std::vector<Test::A*>; // Does not work
|
%template(VecA) std::vector<Test::A*>;
|
||||||
|
|
|
||||||
|
|
@ -24,3 +24,12 @@ bv[3]= 0
|
||||||
|
|
||||||
if bv[0] != bv[2]:
|
if bv[0] != bv[2]:
|
||||||
raise RuntimeError,"bad std::vector<bool> mapping"
|
raise RuntimeError,"bad std::vector<bool> mapping"
|
||||||
|
|
||||||
|
b = B(5)
|
||||||
|
va = VecA([b,b,b,b])
|
||||||
|
if va[0].f(1) != 6:
|
||||||
|
raise RuntimeError,"bad std::vector<A*> mapping"
|
||||||
|
|
||||||
|
b.val = 7
|
||||||
|
if va[3].f(1) != 8:
|
||||||
|
raise RuntimeError,"bad std::vector<A*> mapping"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue