From: Nathan Binkert Date: Sun, 23 Jan 2011 05:48:06 +0000 (-0800) Subject: refcnt: Change things around so that we handle constness correctly. X-Git-Tag: stable_2012_02_02~630 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=048b1e5843494be33b08cd42a3f0bb16e5d320cc;p=gem5.git refcnt: Change things around so that we handle constness correctly. To use a non const pointer: typedef RefCountingPtr FooPtr; To use a const pointer: typedef RefCountingPtr ConstFooPtr; --- diff --git a/src/base/refcnt.hh b/src/base/refcnt.hh index b73183a1a..1c10cc0ea 100644 --- a/src/base/refcnt.hh +++ b/src/base/refcnt.hh @@ -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)