From: Wolfgang Bangerth Date: Fri, 6 Sep 2024 21:21:46 +0000 (-0600) Subject: Rename a member of class SmartPointer. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=380141d417ece2cd24a955137828461a6c584d92;p=dealii.git Rename a member of class SmartPointer. --- diff --git a/include/deal.II/base/smartpointer.h b/include/deal.II/base/smartpointer.h index 93f90f7abe..50197b318f 100644 --- a/include/deal.II/base/smartpointer.h +++ b/include/deal.II/base/smartpointer.h @@ -243,11 +243,9 @@ public: private: /** - * Pointer to the object we want to subscribe to. Since it is often - * necessary to follow this pointer when debugging, we have deliberately - * chosen a short name. + * Pointer to the object we want to subscribe to. */ - T *t; + T *pointer; /** * The identification for the subscriptor. @@ -267,7 +265,7 @@ private: template inline SmartPointer::SmartPointer() - : t(nullptr) + : pointer(nullptr) , id(typeid(P).name()) , pointed_to_object_is_alive(false) {} @@ -276,7 +274,7 @@ inline SmartPointer::SmartPointer() template inline SmartPointer::SmartPointer(T *t) - : t(t) + : pointer(t) , id(typeid(P).name()) , pointed_to_object_is_alive(false) { @@ -288,12 +286,12 @@ inline SmartPointer::SmartPointer(T *t) template inline SmartPointer::SmartPointer(T *t, const std::string &id) - : t(t) + : pointer(t) , id(id) , pointed_to_object_is_alive(false) { - if (t != nullptr) - t->subscribe(&pointed_to_object_is_alive, id); + if (pointer != nullptr) + pointer->subscribe(&pointed_to_object_is_alive, id); } @@ -301,7 +299,7 @@ inline SmartPointer::SmartPointer(T *t, const std::string &id) template template inline SmartPointer::SmartPointer(const SmartPointer &other) - : t(other.t) + : pointer(other.pointer) , id(other.id) , pointed_to_object_is_alive(false) { @@ -310,7 +308,7 @@ inline SmartPointer::SmartPointer(const SmartPointer &other) 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); + pointer->subscribe(&pointed_to_object_is_alive, id); } } @@ -318,7 +316,7 @@ inline SmartPointer::SmartPointer(const SmartPointer &other) template inline SmartPointer::SmartPointer(const SmartPointer &other) - : t(other.t) + : pointer(other.pointer) , id(other.id) , pointed_to_object_is_alive(false) { @@ -327,7 +325,7 @@ inline SmartPointer::SmartPointer(const SmartPointer &other) 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); + pointer->subscribe(&pointed_to_object_is_alive, id); } } @@ -335,7 +333,7 @@ inline SmartPointer::SmartPointer(const SmartPointer &other) template inline SmartPointer::SmartPointer(SmartPointer &&other) noexcept - : t(other.t) + : pointer(other.pointer) , id(other.id) , pointed_to_object_is_alive(false) { @@ -347,7 +345,7 @@ inline SmartPointer::SmartPointer(SmartPointer &&other) noexcept try { - t->subscribe(&pointed_to_object_is_alive, id); + pointer->subscribe(&pointed_to_object_is_alive, id); } catch (...) { @@ -369,8 +367,8 @@ inline SmartPointer::SmartPointer(SmartPointer &&other) noexcept template inline SmartPointer::~SmartPointer() { - if (pointed_to_object_is_alive && t != nullptr) - t->unsubscribe(&pointed_to_object_is_alive, id); + if (pointed_to_object_is_alive && pointer != nullptr) + pointer->unsubscribe(&pointed_to_object_is_alive, id); } @@ -379,13 +377,13 @@ template inline void SmartPointer::clear() { - if (pointed_to_object_is_alive && t != nullptr) + if (pointed_to_object_is_alive && pointer != nullptr) { - t->unsubscribe(&pointed_to_object_is_alive, id); - delete t; + pointer->unsubscribe(&pointed_to_object_is_alive, id); + delete pointer; Assert(pointed_to_object_is_alive == false, ExcInternalError()); } - t = nullptr; + pointer = nullptr; } @@ -395,17 +393,17 @@ inline SmartPointer & SmartPointer::operator=(T *tt) { // optimize if no real action is requested - if (t == tt) + if (pointer == tt) return *this; // Let us unsubscribe from the current object - if (pointed_to_object_is_alive && t != nullptr) - t->unsubscribe(&pointed_to_object_is_alive, id); + if (pointed_to_object_is_alive && pointer != nullptr) + pointer->unsubscribe(&pointed_to_object_is_alive, id); // Then reset to the new object, and subscribe to it - t = tt; + pointer = tt; if (tt != nullptr) - t->subscribe(&pointed_to_object_is_alive, id); + pointer->subscribe(&pointed_to_object_is_alive, id); return *this; } @@ -424,17 +422,17 @@ SmartPointer::operator=(const SmartPointer &other) return *this; // Let us unsubscribe from the current object - if (pointed_to_object_is_alive && t != nullptr) - t->unsubscribe(&pointed_to_object_is_alive, id); + if (pointed_to_object_is_alive && pointer != nullptr) + pointer->unsubscribe(&pointed_to_object_is_alive, id); // Then reset to the new object, and subscribe to it - t = (other != nullptr ? other.get() : nullptr); + pointer = (other != nullptr ? other.get() : nullptr); if (other != nullptr) { 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); + pointer->subscribe(&pointed_to_object_is_alive, id); } return *this; } @@ -452,17 +450,17 @@ SmartPointer::operator=(const SmartPointer &other) return *this; // Let us unsubscribe from the current object - if (pointed_to_object_is_alive && t != nullptr) - t->unsubscribe(&pointed_to_object_is_alive, id); + if (pointed_to_object_is_alive && pointer != nullptr) + pointer->unsubscribe(&pointed_to_object_is_alive, id); // Then reset to the new object, and subscribe to it - t = (other != nullptr ? other.get() : nullptr); + pointer = (other != nullptr ? other.get() : nullptr); if (other != nullptr) { 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); + pointer->subscribe(&pointed_to_object_is_alive, id); } return *this; } @@ -482,17 +480,17 @@ SmartPointer::operator=(SmartPointer &&other) noexcept 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); + if (pointer != nullptr && pointed_to_object_is_alive) + pointer->unsubscribe(&pointed_to_object_is_alive, id); // Then reset to the new object, and subscribe to it: 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 = other.get(); + pointer = other.get(); try { - t->subscribe(&pointed_to_object_is_alive, id); + pointer->subscribe(&pointed_to_object_is_alive, id); } catch (...) { @@ -514,7 +512,7 @@ SmartPointer::operator=(SmartPointer &&other) noexcept template inline SmartPointer::operator T *() const { - return t; + return pointer; } @@ -523,10 +521,10 @@ template inline T & SmartPointer::operator*() const { - Assert(t != nullptr, ExcNotInitialized()); + Assert(pointer != nullptr, ExcNotInitialized()); Assert(pointed_to_object_is_alive, ExcMessage("The object pointed to is not valid anymore.")); - return *t; + return *pointer; } @@ -535,10 +533,10 @@ template inline T * SmartPointer::get() const { - Assert(t != nullptr, ExcNotInitialized()); + Assert(pointer != nullptr, ExcNotInitialized()); Assert(pointed_to_object_is_alive, ExcMessage("The object pointed to is not valid anymore.")); - return t; + return pointer; } @@ -558,11 +556,11 @@ inline void SmartPointer::swap(SmartPointer &other) { #ifdef DEBUG - SmartPointer aux(t, id); + SmartPointer aux(pointer, id); *this = other; other = aux; #else - std::swap(t, other.t); + std::swap(pointer, other.pointer); #endif } @@ -572,13 +570,13 @@ template inline void SmartPointer::swap(T *&ptr) { - if (pointed_to_object_is_alive && t != nullptr) - t->unsubscribe(pointed_to_object_is_alive, id); + if (pointed_to_object_is_alive && pointer != nullptr) + pointer->unsubscribe(pointed_to_object_is_alive, id); - std::swap(t, ptr); + std::swap(pointer, ptr); - if (t != nullptr) - t->subscribe(pointed_to_object_is_alive, id); + if (pointer != nullptr) + pointer->subscribe(pointed_to_object_is_alive, id); }