PageRenderTime 17ms CodeModel.GetById 15ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Swig | 37 lines | 32 code | 5 blank | 0 comment | 0 complexity | 9566a9a5ebe6d058b14ab700a4f8a779 MD5 | raw file
 1%module smart_pointer_template_const_overload
 2
 3%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED) SmartPointer<FooImplementation>::operator->;      // Overloaded method SmartPointer< FooImplementation >::operator ->() ignored
 4
 5%inline %{
 6  template <class T> class SmartPointer {
 7    T *ptr;
 8  public:
 9    SmartPointer(T *t = 0) : ptr(t) {}
10    inline const T * operator->() const { return ptr; }
11    inline T * operator->() { return ptr; }
12  };
13
14  class FooImplementation {
15  public:
16    int mingy() { return 0; }
17    int constmingy() const { return 0; }
18    static int thingy() { return 0; }
19    static int svariable;
20    static const int constsvariable;
21    int normalvariable;
22  };
23  int FooImplementation::svariable = 0;
24  const int FooImplementation::constsvariable = 2;
25
26  void tester() {
27    SmartPointer<FooImplementation> p;
28    p->mingy();
29    p->constmingy();
30    p->thingy();
31    int a = p->svariable;
32    a = p->constsvariable;
33    a = p->normalvariable;
34  }
35%}
36
37%template(FooSmartPointer) SmartPointer<FooImplementation>;