4
// activate the automatic comparison methods generation (==,!=,...)
8
#include <algorithm> // for std::swap
14
%include std_complex.i
32
%std_comp_methods(std::pair<std::string, int>);
35
%template(CIntPair) pair<const int, const int>;
36
%template() pair<double, double>;
37
%template(IntPair) pair<int, int>;
38
%template(SIPair) pair<std::string, int>;
39
%template(CIPair) pair<std::complex<double>, int>;
40
%template(SIIPair) pair<std::pair<std::string, int>, int>;
41
%template(AIntPair) pair<A, int>;
43
%template(CCIntPair) pair<const A, const pair<int, int> >;
45
%template(ABPair) pair<A, B>;
46
%template(IntAPair) pair<int, A>;
48
%template(pairP1) pair<int, A*>;
49
%template(pairP2) pair<A*, int>;
50
%template(pairP3) pair<A*, A*>;
51
%template(pairP4) pair<int, int*>;
52
%template(pairP5) pair<int*, int>;
53
%template(pairP6) pair<int*, int*>;
56
%std_comp_methods(std::pair<std::pair<std::string, int>, int>);
58
%apply std::pair<int,int> *INOUT {std::pair<int,int> *INOUT2};
62
/* Test the "out" typemap for pair<T, U> */
63
std::pair<int, int> makeIntPair(int a, int b) {
64
return std::make_pair(a, b);
68
* There is no "out" typemap for a pointer to a pair, so
69
* this should return a wrapped instance of a std::pair
70
* instead of the native "array" type for the target language.
72
std::pair<int, int> * makeIntPairPtr(int a, int b) {
73
static std::pair<int, int> p = std::make_pair(a, b);
78
* There is no "out" typemap for a non-const reference to a pair, so
79
* this should return a wrapped instance of a std::pair instead of
80
* the native "array" type for the target language.
82
std::pair<int, int>& makeIntPairRef(int a, int b) {
83
static std::pair<int, int> p = std::make_pair(a, b);
88
* There is no "out" typemap for a const reference to a pair, so
89
* this should return a wrapped instance of a std::pair
90
* instead of the native "array" type for the target language.
92
const std::pair<int, int> & makeIntPairConstRef(int a, int b) {
93
static std::pair<int, int> p = std::make_pair(a, b);
97
/* Test the "in" typemap for pair<T, U> */
98
int product1(std::pair<int, int> p) {
99
return p.first*p.second;
102
/* Test the "in" typemap for const pair<T, U>& */
103
int product2(const std::pair<int, int>& p) {
104
return p.first*p.second;
108
p_ident(std::pair<int, int> p, const std::pair<int, int>& q) {
114
p_identa(const std::pair<int, A*>& p) {
119
d_inout(double *INOUT) {
124
d_inout(int *INOUT) {
129
d_inout2(double *INOUT) {
135
p_inout(std::pair<int, int> *INOUT) {
136
std::swap(INOUT->first, INOUT->second);
140
p_inout2(std::pair<int, int> *INOUT) {
141
std::swap(INOUT->first, INOUT->second);
146
p_inout3(std::pair<int,int> *INOUT, std::pair<int,int> *INOUT2) {
147
std::swap(*INOUT, *INOUT2);
151
p_inoutd(std::pair<double, double> *INOUT) {
152
std::swap(INOUT->first, INOUT->second);
156
s_ident(const std::string& s) {
161
std::pair<char, char>
162
p_ident(std::pair<char, char> p, const std::pair<char, char>& q) {
166
/* Test the "in" typemap for const pair<T, U>* */
168
p_ident(std::pair<A, B> p, const std::pair<A, B>& q) {
172
/* Test the "in" typemap for const pair<T, U>* */
174
p_ident(std::pair<int, A> p, const std::pair<int, A>& q) {
180
p_ident(std::pair<int, int> p, const std::pair<A, int>& q) {
185
p_ident(std::pair<int, int> p, const std::pair<A, B>& q) {
197
%template(paircA1) pair<const int, A*>;
198
%template(paircA2) pair<const int, const A*>;
199
%template(pairiiA) pair<int,pair<int, A*> >;