47 #ifndef COMMONCPP_POINTER_H_ 48 #define COMMONCPP_POINTER_H_ 50 #ifndef COMMONCPP_CONFIG_H_ 51 #include <commoncpp/config.h> 69 inline void ptrDetach(
void) {
70 if(ptrCount && --(*ptrCount)==0) {
79 inline explicit Pointer(T* ptr = NULL) : ptrObject(ptr) {
80 ptrCount =
new unsigned;
85 ptrObject = ref.ptrObject;
86 ptrCount = ref.ptrCount;
97 ptrObject = ref.ptrObject;
98 ptrCount = ref.ptrCount;
104 inline T& operator*()
const {
108 inline T* getObject()
const {
112 inline T* operator->()
const {
116 inline operator bool()
const {
117 return (*ptrCount != 1);
120 inline bool operator!()
const {
121 return (*ptrCount == 1);
124 inline int operator++()
const {
125 return ++(*ptrCount);
128 inline int operator--()
const {
133 return --(*ptrCount);
Used to create and manage referece counted pointers.