Add an operator overload for ManagedType.

master v1.3.3
Jonathan Protzenko 2015-11-02 13:20:38 -08:00
parent 83a261d23f
commit 88b37e83bb
2 changed files with 29 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
build
.yotta.json
yotta_modules
yotta_targets

View File

@ -80,10 +80,35 @@ public:
*/
int getReferences();
/**
* De-reference operator overload. This makes modifying ref-counted POD
* easier.
*
* Example:
* @code
* ManagedType<int> x = 0;
* *x = 1; // mutates the ref-counted integer
*/
T& operator*() {
return *object;
}
/**
* Method call operator overload. This forwards the call to the underlying
* object.
*
* Example:
* @code
* ManagedType<T> x = new T();
* x->m(); // resolves to T::m
*/
T* operator->() {
return object;
}
/**
* x.get() is shorthand for x.operator->()
*/
T* get() {
return object;
}