template<typename TYPE>
class Scoped< TYPE >
Scoped is convenience class that give block scoping to reference counted Objects. Scoped<TYPE> tries to act like a TYPE *.
As a convenience class you don't have to use it. Some people find it easier to manage the reference counting themselves.
Example: Without Scoped:
* {
*
FileIO *file = FileIO::create();
* try
* {
* file->
init(path, mode);
*
* if(return early)
* {
* return;
* }
*
* }
* catch(...)
* {
* throw;
* }
* }
*
With Scoped:
* {
* file->
init(path, mode);
*
* if(return early)
* return;
*
* }
*
- Note
- be careful when using this outside of blocked scope. The = operator increments the count which can lead to memory leaks.
Definition at line 158 of file Object.h.