From 46e7328de65f2093ff93bba148ba839611d336aa Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 28 Jan 2021 16:32:07 -0800 Subject: [PATCH] base: Style fixes in base/refcnt.hh Change-Id: I8f4b2710bea1fe15baa1b482ff62fbab645a3690 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40095 Reviewed-by: Daniel Carvalho Maintainer: Gabe Black Tested-by: kokoro --- src/base/refcnt.hh | 59 +++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/src/base/refcnt.hh b/src/base/refcnt.hh index 263666ea8..3106a6fa6 100644 --- a/src/base/refcnt.hh +++ b/src/base/refcnt.hh @@ -96,7 +96,12 @@ class RefCounted /// Decrement the reference count and destroy the object if all /// references are gone. - void decref() const { if (--count <= 0) delete this; } + void + decref() const + { + if (--count <= 0) + delete this; + } }; /** @@ -228,11 +233,15 @@ class RefCountingPtr const RefCountingPtr &operator=(T *p) { set(p); return *this; } /// Copy the pointer from another RefCountingPtr - const RefCountingPtr &operator=(const RefCountingPtr &r) - { return operator=(r.data); } + const RefCountingPtr & + operator=(const RefCountingPtr &r) + { + return operator=(r.data); + } /// Move-assign the pointer from another RefCountingPtr - const RefCountingPtr &operator=(RefCountingPtr&& r) + const RefCountingPtr & + operator=(RefCountingPtr&& r) { /* This happens regardless of whether the pointer is the same or not, * because of the move semantics, the rvalue needs to be 'destroyed'. @@ -252,36 +261,54 @@ class RefCountingPtr /// Check for equality of two reference counting pointers. template -inline bool operator==(const RefCountingPtr &l, const RefCountingPtr &r) -{ return l.get() == r.get(); } +inline bool +operator==(const RefCountingPtr &l, const RefCountingPtr &r) +{ + return l.get() == r.get(); +} /// Check for equality of of a reference counting pointers and a /// regular pointer template -inline bool operator==(const RefCountingPtr &l, const T *r) -{ return l.get() == r; } +inline bool +operator==(const RefCountingPtr &l, const T *r) +{ + return l.get() == r; +} /// Check for equality of of a reference counting pointers and a /// regular pointer template -inline bool operator==(const T *l, const RefCountingPtr &r) -{ return l == r.get(); } +inline bool +operator==(const T *l, const RefCountingPtr &r) +{ + return l == r.get(); +} /// Check for inequality of two reference counting pointers. template -inline bool operator!=(const RefCountingPtr &l, const RefCountingPtr &r) -{ return l.get() != r.get(); } +inline bool +operator!=(const RefCountingPtr &l, const RefCountingPtr &r) +{ + return l.get() != r.get(); +} /// Check for inequality of of a reference counting pointers and a /// regular pointer template -inline bool operator!=(const RefCountingPtr &l, const T *r) -{ return l.get() != r; } +inline bool +operator!=(const RefCountingPtr &l, const T *r) +{ + return l.get() != r; +} /// Check for inequality of of a reference counting pointers and a /// regular pointer template -inline bool operator!=(const T *l, const RefCountingPtr &r) -{ return l != r.get(); } +inline bool +operator!=(const T *l, const RefCountingPtr &r) +{ + return l != r.get(); +} #endif // __BASE_REFCNT_HH__ -- 2.30.2