%module li_std_vector %include "std_vector.i" %{ #include #include #include %} namespace std { %template(IntVector) vector; } %template(DoubleVector) std::vector; %inline %{ typedef float Real; %} namespace std { %template(RealVector) vector; } %inline %{ double average(std::vector v) { return std::accumulate(v.begin(),v.end(),0.0)/v.size(); } std::vector half(const std::vector& v) { std::vector w(v); for (std::vector::size_type i=0; i& v) { std::transform(v.begin(),v.end(),v.begin(), std::bind2nd(std::divides(),2.0)); } struct Struct { double num; Struct() : num(0.0) {} Struct(double d) : num(d) {} // bool operator==(const Struct &other) { return (num == other.num); } }; %} #ifndef SWIGCSHARP // Can't do vectors of pointers yet %template(IntPtrVector) std::vector; #endif %template(StructVector) std::vector;