#include <Object.h>
Public Member Functions | |
~Scoped (void) | |
Releases the object when Scoped<> goes out of scope. | |
Scoped (void) | |
Create an object on the heap. | |
Scoped (TYPE *object) | |
Manage an existing object. | |
Scoped & | operator= (TYPE *object) |
Assignment operator. | |
Scoped (const Scoped &object) | |
Copy constructor. | |
Scoped & | operator= (const Scoped &object) |
Assignment operator. | |
TYPE * | operator-> (void) |
Make Scoped behave like a pointer to TYPE. | |
TYPE & | operator* (void) |
Make Scoped behave like a pointer to TYPE. | |
operator TYPE *& (void) | |
Make Scoped behave like a pointer to 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); // use the file object if(return early) { file->release(); return; } // use the file object some more file->release(); } catch(...) { file->release(); throw; } }
{ Scoped<FileIO> file; file->init(path, mode); // use the file object if(return early) return; // use the file object some more }
Definition at line 158 of file Object.h.
TYPE* Scoped< TYPE >::operator-> | ( | void | ) | [inline] |
TYPE& Scoped< TYPE >::operator* | ( | void | ) | [inline] |
Scoped< TYPE >::operator TYPE *& | ( | void | ) | [inline] |
LizardTech |