PageRenderTime 18ms CodeModel.GetById 13ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/test-suite/template_ns.i

#
Swig | 35 lines | 28 code | 7 blank | 0 comment | 0 complexity | 30824e9900c565de41079d2c6216fc8f MD5 | raw file
 1// Tests the use of the %template directive with fully
 2// qualified scope names
 3
 4%module template_ns
 5
 6%warnfilter(SWIGWARN_RUBY_WRONG_NAME) std::my_pair<int, int>;       /* Ruby, wrong class name */
 7%warnfilter(SWIGWARN_RUBY_WRONG_NAME) std::my_pair<double, double>; /* Ruby, wrong class name */
 8
 9%ignore std::my_pair::my_pair();
10
11%inline %{
12namespace std
13{
14template <class _T1, class _T2>
15struct my_pair {
16  typedef _T1 first_type; 
17  typedef _T2 second_type;
18
19  _T1 first;              
20  _T2 second;             
21  my_pair() : first(_T1()), second(_T2()) {}
22  my_pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {}
23  template <class _U1, class _U2>
24  my_pair(const my_pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
25};
26}
27%}
28
29// Add copy constructor
30%extend std::my_pair {
31   %template(pair) my_pair<_T1,_T2>;
32};
33
34%template(pairii) std::my_pair<int,int>;
35%template(pairdd) std::my_pair<double,double>;