Hello all,

I met problem when wrapping C++ to Ruby with SWIG related statement using ::std::vector in c++ header file. It seems that SWIG does not recognize "using ::std::vector" statement. I am using swig 2.0.8. I don't know if my have a wrong usage or SWIG does not support it.

after running the ruby script at the end, it reports "undefined method size()" for the last line.
If I remove "using ::std::vector" in the header file. And change the signature of "vector<Animal> getAnimals()" to "std::vector<Animal> getAnimals()", the ruby script works good.

Can you provide any hints?

Thanks a lot!

Best Regards,
Fiona Xu

Here is my .i file.
#include "Animal.hpp"

%include "std_string.i"
%include "std_vector.i"
%include "Animal.hpp"

%template(StringVector) std::vector<std::string>;
%template(IntVector) std::vector<int>;
%ignore std::vector<Animal>::resize(size_type);
%ignore std::vector<Animal>::vector(size_type);

%template(AnimalVector) vector<Animal>;

Here is my .hpp file.
#include <string>
#include <vector>

using ::std::vector;
using ::std::string

class Animal{
    std::string getName();
    vector<Animal> getAnimals();

Here is my ruby script.

cat = Example::Animal.new("cat");
animal = Example::AnimalVector.new();

dog = Example::Animal.new("dog");
for i in 0..1
    printf "name is: %s\n", animal[i].getName();

animals = cat.getAnimals();
printf "There are : %d animals\n", animals.size;