--------------------- PatchSet 139 Date: 2002/11/08 12:16:50 Author: rbcollins Branch: refcount Tag: (none) Log: handle const pointers too - more cases Members: include/RefCount.h:1.1.2.6->1.1.2.7 test-suite/refcount.cc:1.1.2.5->1.1.2.6 Index: squid3/include/RefCount.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/include/RefCount.h,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- squid3/include/RefCount.h 8 Nov 2002 12:04:57 -0000 1.1.2.6 +++ squid3/include/RefCount.h 8 Nov 2002 12:16:50 -0000 1.1.2.7 @@ -1,6 +1,6 @@ /* - * $Id: RefCount.h,v 1.1.2.6 2002/11/08 12:04:57 rbcollins Exp $ + * $Id: RefCount.h,v 1.1.2.7 2002/11/08 12:16:50 rbcollins Exp $ * * DEBUG: section xx Refcount allocator * AUTHOR: Robert Collins @@ -58,12 +58,12 @@ p_ = p.p_; return *this; } - C * operator-> () const {return p_; } + C const * operator-> () const {return p_; } C * operator-> () {return const_cast(p_); } - C & operator * () const {return *p_; } + C const & operator * () const {return *p_; } C & operator * () {return *const_cast(p_); } C const * getRaw() const{return p_; } - C const * getRaw() {return p_; } + C * getRaw() {return const_cast(p_); } bool operator == (const RefCount& p) const { return p.p_ == p_; Index: squid3/test-suite/refcount.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/test-suite/refcount.cc,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- squid3/test-suite/refcount.cc 8 Nov 2002 12:04:57 -0000 1.1.2.5 +++ squid3/test-suite/refcount.cc 8 Nov 2002 12:16:51 -0000 1.1.2.6 @@ -1,6 +1,6 @@ /* - * $Id: refcount.cc,v 1.1.2.5 2002/11/08 12:04:57 rbcollins Exp $ + * $Id: refcount.cc,v 1.1.2.6 2002/11/08 12:16:51 rbcollins Exp $ * * DEBUG: section xx Refcount allocator * AUTHOR: Robert Collins @@ -107,5 +107,11 @@ _ToRefCount const * aPointer = new _ToRefCount; ToRefCount anObject (aPointer); } + /* Can we get a pointer to nonconst from a nonconst refcounter */ + { + ToRefCount anObject (new _ToRefCount); + _ToRefCount *aPointer = anObject.getRaw(); + aPointer = NULL; + } return _ToRefCount::Instances == 0 ? 0 : 1; }