#include <AsPtr.h>
Public Member Functions | |
| AsPtr (const T &object) | |
| AsPtr (const AsPtr &object) | |
| const T * | operator-> () const |
| T * | operator-> () |
| operator T* () | |
| const T & | operator* () const |
| T & | operator* () |
| bool | operator== (const AsPtr &ob2) const |
makes an object to behave as a pointer Example: you can use a object as argument for a MEncapsulate. Suppose you have the code: struct Test { void funcion(){}; }
Test test; makeMemberEncapsulate( &Test::funcion, &test ); ... save the created object somewhere or post to a thread,... previous code is incorrect because test is local, so &test will point to a local variable that is destroyed becasue the result of makeMemberEncapsulate is used outside this scope. The solution is: makeMemberEncapsulate( &Test::funcion, asPtr( test ) ) This way asPtr makes MEncapsulate believe that test is a pointer holding an internal copy of test