refcnt: Change things around so that we handle constness correctly.
To use a non const pointer: typedef RefCountingPtr<Foo> FooPtr; To use a const pointer: typedef RefCountingPtr<const Foo> ConstFooPtr;
This commit is contained in:
parent
0e64e1be0f
commit
048b1e5843
1 changed files with 4 additions and 8 deletions
|
@ -34,7 +34,7 @@
|
|||
class RefCounted
|
||||
{
|
||||
private:
|
||||
int count;
|
||||
mutable int count;
|
||||
|
||||
private:
|
||||
// Don't allow a default copy constructor or copy operator on
|
||||
|
@ -84,13 +84,9 @@ class RefCountingPtr
|
|||
RefCountingPtr(const RefCountingPtr &r) { copy(r.data); }
|
||||
~RefCountingPtr() { del(); }
|
||||
|
||||
T *operator->() { return data; }
|
||||
T &operator*() { return *data; }
|
||||
T *get() { return data; }
|
||||
|
||||
const T *operator->() const { return data; }
|
||||
const T &operator*() const { return *data; }
|
||||
const T *get() const { return data; }
|
||||
T *operator->() const { return data; }
|
||||
T &operator*() const { return *data; }
|
||||
T *get() const { return data; }
|
||||
|
||||
const RefCountingPtr &operator=(T *p) { set(p); return *this; }
|
||||
const RefCountingPtr &operator=(const RefCountingPtr &r)
|
||||
|
|
Loading…
Reference in a new issue