%module li_std_pair %include "std_pair.i" namespace std { %template(IntPair) pair; } %inline %{ /* Test the "out" typemap for pair */ std::pair makeIntPair(int a, int b) { return std::make_pair(a, b); } /** * There is no "out" typemap for a pointer to a pair, so * this should return a wrapped instance of a std::pair * instead of the native "array" type for the target language. */ std::pair * makeIntPairPtr(int a, int b) { static std::pair p = std::make_pair(a, b); return &p; } /** * There is no "out" typemap for a non-const reference to a pair, so * this should return a wrapped instance of a std::pair instead of * the native "array" type for the target language. */ std::pair& makeIntPairRef(int a, int b) { static std::pair p = std::make_pair(a, b); return p; } /** * There is no "out" typemap for a const reference to a pair, so * this should return a wrapped instance of a std::pair * instead of the native "array" type for the target language. */ const std::pair & makeIntPairConstRef(int a, int b) { static std::pair p = std::make_pair(a, b); return p; } /* Test the "in" typemap for pair */ int product1(std::pair p) { return p.first*p.second; } /* Test the "in" typemap for const pair& */ int product2(const std::pair& p) { return p.first*p.second; } /* Test the "in" typemap for const pair* */ int product3(const std::pair *p) { return p->first*p->second; } %} // Test that the digraph <::aa::Holder> is not generated for stl containers %include %inline %{ namespace aa { struct Holder { Holder(int n = 0) : number(n) {} int number; }; } %} %template(PairTest) std::pair< ::aa::Holder, int >; %inline %{ std::pair< ::aa::Holder, int > pair1(std::pair< ::aa::Holder, int > x) { return x; } %}