2

I want to wrap a C++ vector of vectors to Python code by using SWIG.

Is it possible to wrap this type of vector of vectors?

std::vector<std::vector<MyClass*>>;

In the interface file MyApplication.i I added these lines:

%include "std_vector.i"
%{ 
#include <vector> 
%} 

namespace std {
   %template(VectorOfStructVector) vector<vector<MyClass*>>;
}

But, I'm getting an Error when SWIG is executed. I'm able to wrap this type (using reference to the vector):

 std::vector<std::vector<MyClass*>*>;

But, it's not working properly, I cannot access the items. That's why I'm interested in this type (without the reference):

 std::vector<std::vector<MyClass*>>;

Any ideas?

Dominic Rodger
  • 97,747
  • 36
  • 197
  • 212
Javier
  • 51
  • 2
  • 6

1 Answers1

4

Is it a C++ parsing issue?

 std::vector<std::vector<MyClass*> >;
 ---Important space---------------^
Charles Beattie
  • 5,739
  • 1
  • 29
  • 32
  • Also this line was needed in the interface file: %template(VectorOfStructVector) vector >; – Javier Sep 21 '10 at 21:52
  • @Javier, another solution is to compile with "--std=c++0x" if you're using gcc. C++0x has fixed this problem. – Neil G Mar 10 '11 at 08:01