summaryrefslogtreecommitdiff
path: root/Examples/test-suite/cpp11_shared_ptr_const.i
blob: 5e38123b48097fba632fc656fd81e3424e344a03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
%module cpp11_shared_ptr_const

%{

#include <memory>
#include <vector>

class Foo
{
  int m;
public:
  Foo(int i) : m(i) {}
  int get_m() { return m;}
};

std::shared_ptr<Foo> foo(Foo v) {
  return std::shared_ptr<Foo>(new Foo(v));
}

std::shared_ptr<const Foo> const_foo(Foo v) {
  return std::shared_ptr<const Foo>(new Foo(v));
}

std::vector<std::shared_ptr<Foo> > foo_vec(Foo v) {
    std::vector<std::shared_ptr<Foo> > result;
    result.push_back( std::shared_ptr<Foo>(new Foo(v)) );
    return result;
}

std::vector<std::shared_ptr<const Foo> > const_foo_vec(Foo v) {
  std::vector<std::shared_ptr<const Foo> > result;
  result.push_back( std::shared_ptr<Foo>(new Foo(v)) );
  return result;
}

%}

%include <std_shared_ptr.i>
%include <std_vector.i>

%shared_ptr(Foo);

%template (FooVector) std::vector<std::shared_ptr<Foo> >;
%template (FooConstVector) std::vector<std::shared_ptr<Foo const> >;

class Foo
{
  int m;
public:
  Foo(int i);
  int get_m();
};
std::shared_ptr<Foo> foo(Foo v);
std::shared_ptr<const Foo> const_foo(Foo v);
std::vector<std::shared_ptr<Foo> > foo_vec(Foo v) const;
std::vector<std::shared_ptr<const Foo> > const_foo_vec(Foo v) const;