From c0824888de2dccba313b827fc896eb04cc3c351c Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 6 Sep 2024 11:55:00 -0600 Subject: [PATCH] Rename function arguments in SmartPointer. --- include/deal.II/base/smartpointer.h | 90 ++++++++++++++--------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/include/deal.II/base/smartpointer.h b/include/deal.II/base/smartpointer.h index 5e39ead3f8..93f90f7abe 100644 --- a/include/deal.II/base/smartpointer.h +++ b/include/deal.II/base/smartpointer.h @@ -103,18 +103,18 @@ public: * to from tt, but subscribe ourselves to it again. */ template - SmartPointer(const SmartPointer &tt); + SmartPointer(const SmartPointer &other); /** * Copy constructor for SmartPointer. We do not copy the object subscribed * to from tt, but subscribe ourselves to it again. */ - SmartPointer(const SmartPointer &tt); + SmartPointer(const SmartPointer &other); /** * Move constructor for SmartPointer. */ - SmartPointer(SmartPointer &&tt) noexcept; + SmartPointer(SmartPointer &&other) noexcept; /** * Constructor taking a normal pointer. If possible, i.e. if the pointer is @@ -154,20 +154,20 @@ public: */ template SmartPointer & - operator=(const SmartPointer &tt); + operator=(const SmartPointer &other); /** * Assignment operator for SmartPointer. The pointer subscribes to the new * object automatically and unsubscribes to an old one if it exists. */ SmartPointer & - operator=(const SmartPointer &tt); + operator=(const SmartPointer &other); /** * Move assignment operator for SmartPointer. */ SmartPointer & - operator=(SmartPointer &&tt) noexcept; + operator=(SmartPointer &&other) noexcept; /** * Delete the object pointed to and set the pointer to nullptr. Note @@ -231,7 +231,7 @@ public: * the pointer variable which we are given. */ void - swap(T *&tt); + swap(T *&ptr); /** * Return an estimate of the amount of memory (in bytes) used by this class. @@ -300,14 +300,14 @@ inline SmartPointer::SmartPointer(T *t, const std::string &id) template template -inline SmartPointer::SmartPointer(const SmartPointer &tt) - : t(tt.t) - , id(tt.id) +inline SmartPointer::SmartPointer(const SmartPointer &other) + : t(other.t) + , id(other.id) , pointed_to_object_is_alive(false) { - if (tt != nullptr) + if (other != nullptr) { - Assert(tt.pointed_to_object_is_alive, + Assert(other.pointed_to_object_is_alive, ExcMessage("You can't copy a smart pointer object that " "is pointing to an object that is no longer alive.")); t->subscribe(&pointed_to_object_is_alive, id); @@ -317,14 +317,14 @@ inline SmartPointer::SmartPointer(const SmartPointer &tt) template -inline SmartPointer::SmartPointer(const SmartPointer &tt) - : t(tt.t) - , id(tt.id) +inline SmartPointer::SmartPointer(const SmartPointer &other) + : t(other.t) + , id(other.id) , pointed_to_object_is_alive(false) { - if (tt != nullptr) + if (other != nullptr) { - Assert(tt.pointed_to_object_is_alive, + Assert(other.pointed_to_object_is_alive, ExcMessage("You can't copy a smart pointer object that " "is pointing to an object that is no longer alive.")); t->subscribe(&pointed_to_object_is_alive, id); @@ -334,14 +334,14 @@ inline SmartPointer::SmartPointer(const SmartPointer &tt) template -inline SmartPointer::SmartPointer(SmartPointer &&tt) noexcept - : t(tt.t) - , id(tt.id) +inline SmartPointer::SmartPointer(SmartPointer &&other) noexcept + : t(other.t) + , id(other.id) , pointed_to_object_is_alive(false) { - if (tt != nullptr) + if (other != nullptr) { - Assert(tt.pointed_to_object_is_alive, + Assert(other.pointed_to_object_is_alive, ExcMessage("You can't move a smart pointer object that " "is pointing to an object that is no longer alive.")); @@ -360,7 +360,7 @@ inline SmartPointer::SmartPointer(SmartPointer &&tt) noexcept // Release the rhs object as if we had moved all members away from // it directly: - tt = nullptr; + other = nullptr; } } @@ -415,12 +415,12 @@ SmartPointer::operator=(T *tt) template template inline SmartPointer & -SmartPointer::operator=(const SmartPointer &tt) +SmartPointer::operator=(const SmartPointer &other) { // if objects on the left and right // hand side of the operator= are // the same, then this is a no-op - if (&tt == this) + if (&other == this) return *this; // Let us unsubscribe from the current object @@ -428,10 +428,10 @@ SmartPointer::operator=(const SmartPointer &tt) t->unsubscribe(&pointed_to_object_is_alive, id); // Then reset to the new object, and subscribe to it - t = (tt != nullptr ? tt.get() : nullptr); - if (tt != nullptr) + t = (other != nullptr ? other.get() : nullptr); + if (other != nullptr) { - Assert(tt.pointed_to_object_is_alive, + Assert(other.pointed_to_object_is_alive, ExcMessage("You can't copy a smart pointer object that " "is pointing to an object that is no longer alive.")); t->subscribe(&pointed_to_object_is_alive, id); @@ -443,12 +443,12 @@ SmartPointer::operator=(const SmartPointer &tt) template inline SmartPointer & -SmartPointer::operator=(const SmartPointer &tt) +SmartPointer::operator=(const SmartPointer &other) { // if objects on the left and right // hand side of the operator= are // the same, then this is a no-op - if (&tt == this) + if (&other == this) return *this; // Let us unsubscribe from the current object @@ -456,10 +456,10 @@ SmartPointer::operator=(const SmartPointer &tt) t->unsubscribe(&pointed_to_object_is_alive, id); // Then reset to the new object, and subscribe to it - t = (tt != nullptr ? tt.get() : nullptr); - if (tt != nullptr) + t = (other != nullptr ? other.get() : nullptr); + if (other != nullptr) { - Assert(tt.pointed_to_object_is_alive, + Assert(other.pointed_to_object_is_alive, ExcMessage("You can't copy a smart pointer object that " "is pointing to an object that is no longer alive.")); t->subscribe(&pointed_to_object_is_alive, id); @@ -471,25 +471,25 @@ SmartPointer::operator=(const SmartPointer &tt) template inline SmartPointer & -SmartPointer::operator=(SmartPointer &&tt) noexcept +SmartPointer::operator=(SmartPointer &&other) noexcept { - if (tt == nullptr) + if (other == nullptr) { *this = nullptr; } // if objects on the left and right hand side of the operator= are // the same, then this is a no-op - else if (&tt != this) + else if (&other != this) { // Let us unsubscribe from the current object if (t != nullptr && pointed_to_object_is_alive) t->unsubscribe(&pointed_to_object_is_alive, id); // Then reset to the new object, and subscribe to it: - Assert(tt.pointed_to_object_is_alive, + Assert(other.pointed_to_object_is_alive, ExcMessage("You can't move a smart pointer object that " "is pointing to an object that is no longer alive.")); - t = tt.get(); + t = other.get(); try { t->subscribe(&pointed_to_object_is_alive, id); @@ -504,7 +504,7 @@ SmartPointer::operator=(SmartPointer &&tt) noexcept } // Finally release the rhs object since we moved its contents - tt = nullptr; + other = nullptr; } return *this; } @@ -555,14 +555,14 @@ SmartPointer::operator->() const template template inline void -SmartPointer::swap(SmartPointer &tt) +SmartPointer::swap(SmartPointer &other) { #ifdef DEBUG SmartPointer aux(t, id); - *this = tt; - tt = aux; + *this = other; + other = aux; #else - std::swap(t, tt.t); + std::swap(t, other.t); #endif } @@ -570,12 +570,12 @@ SmartPointer::swap(SmartPointer &tt) template inline void -SmartPointer::swap(T *&tt) +SmartPointer::swap(T *&ptr) { if (pointed_to_object_is_alive && t != nullptr) t->unsubscribe(pointed_to_object_is_alive, id); - std::swap(t, tt); + std::swap(t, ptr); if (t != nullptr) t->subscribe(pointed_to_object_is_alive, id); -- 2.39.5