Changeset 21995bc for src/examples/wrapper/src/pointer.h
- Timestamp:
- May 18, 2016, 11:42:10 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 6e3ae00
- Parents:
- bf1ee05
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/wrapper/src/pointer.h
rbf1ee05 r21995bc 53 53 void ?{}(wrapper_t* this) 54 54 { 55 sout | "Constructing empty ref pointer" | endl ;55 sout | "Constructing empty ref pointer" | endl | endl; 56 56 this->ptr = NULL; 57 57 } … … 62 62 this->ptr = rhs.ptr; 63 63 this->ptr->count++; 64 sout | "Reference is " | this->ptr->count | endl | endl; 64 65 } 65 66 … … 70 71 sout | "Destroying ref pointer" | endl; 71 72 this->ptr->count--; 72 sout | "Reference is " | (int)this->ptr->count| endl;73 sout | "Reference is " | this->ptr->count | endl | endl; 73 74 if(!this->ptr->count) delete(this->ptr); 74 75 } 75 76 else 76 77 { 77 sout | "Destroying empty ref pointer" | endl ;78 sout | "Destroying empty ref pointer" | endl | endl; 78 79 } 80 } 81 82 wrapper_t ?=?(wrapper_t* this, wrapper_t rhs) 83 { 84 sout | "Setting ref pointer" | endl; 85 if(this->ptr) 86 { 87 this->ptr->count--; 88 sout | "Reference is " | this->ptr->count | endl | endl; 89 if(!this->ptr->count) delete(this->ptr); 90 } 91 this->ptr = rhs.ptr; 92 this->ptr->count++; 93 sout | "Reference is " | this->ptr->count | endl | endl; 79 94 } 80 95 … … 84 99 this->ptr->count++; 85 100 sout | "Setting ref pointer" | endl; 86 sout | "Reference is " | this->ptr->count | endl ;101 sout | "Reference is " | this->ptr->count | endl | endl; 87 102 } 103 104 void clear(wrapper_t* this) 105 { 106 sout | "Clearing ref pointer" | endl; 107 this->ptr->count--; 108 sout | "Reference is " | this->ptr->count | endl | endl; 109 if(!this->ptr->count) delete(this->ptr); 110 this->ptr = NULL; 111 } 112 88 113 89 114 wrapper_t wrap(int val)
Note: See TracChangeset
for help on using the changeset viewer.