Smart pointer documentation improvement
This commit is contained in:
parent
67659773cc
commit
f47075ec99
1 changed files with 5 additions and 2 deletions
|
|
@ -4433,7 +4433,7 @@ around some other class. For example:
|
||||||
template<class T> class SmartPtr {
|
template<class T> class SmartPtr {
|
||||||
T *pointee;
|
T *pointee;
|
||||||
public:
|
public:
|
||||||
...
|
SmartPtr(T *p) : pointee(p) { ... }
|
||||||
T *operator->() {
|
T *operator->() {
|
||||||
return pointee;
|
return pointee;
|
||||||
}
|
}
|
||||||
|
|
@ -4453,7 +4453,7 @@ typedef SmartPtr<Foo_Impl> Foo;
|
||||||
|
|
||||||
// Create smart pointer Foo
|
// Create smart pointer Foo
|
||||||
Foo make_Foo() {
|
Foo make_Foo() {
|
||||||
return SmartPtr(new Foo_Impl());
|
return SmartPtr<Foo_Impl>(new Foo_Impl());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do something with smart pointer Foo
|
// Do something with smart pointer Foo
|
||||||
|
|
@ -4461,6 +4461,9 @@ void do_something(Foo f) {
|
||||||
printf("x = %d\n", f->x);
|
printf("x = %d\n", f->x);
|
||||||
f->bar();
|
f->bar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Call the wrapped smart pointer proxy class in the target language 'Foo'
|
||||||
|
%template(Foo) SmartPtr<Foo_Impl>;
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue