summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-09-25 10:15:20 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-09-25 10:15:20 -0400
commit5d7b3abe7759545b5ff12dc8ae5a6de9ed258953 (patch)
treec03053fa561e5e85bd1b18f4f54a71b2bec5a6b4
parent98c829a47cd2b38d51602cce3de873179a394ba7 (diff)
Explain why apparently redundant LLPointer methods are necessary.
Given templated constructors and assignment operators, it's tempting to remove specific constructors and assignment operators with the same LLPointer<Type> parameters. That turns out to be a mistake. Add comments to warn future maintainers.
-rw-r--r--indra/llcommon/llpointer.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h
index c5dd5532cc..71c955c4c5 100644
--- a/indra/llcommon/llpointer.h
+++ b/indra/llcommon/llpointer.h
@@ -61,6 +61,13 @@ public:
ref();
}
+ // Even though the template constructors below accepting
+ // (const LLPointer<Subclass>&) and (LLPointer<Subclass>&&) appear to
+ // subsume these specific (const LLPointer<Type>&) and (LLPointer<Type>&&)
+ // constructors, the compiler recognizes these as The Copy Constructor and
+ // The Move Constructor, respectively. In other words, even in the
+ // presence of the LLPointer<Subclass> constructors, we still must specify
+ // the LLPointer<Type> constructors.
LLPointer(const LLPointer<Type>& ptr) :
mPointer(ptr.mPointer)
{
@@ -126,6 +133,13 @@ public:
return *this;
}
+ // Even though the template assignment operators below accepting
+ // (const LLPointer<Subclass>&) and (LLPointer<Subclass>&&) appear to
+ // subsume these specific (const LLPointer<Type>&) and (LLPointer<Type>&&)
+ // assignment operators, the compiler recognizes these as Copy Assignment
+ // and Move Assignment, respectively. In other words, even in the presence
+ // of the LLPointer<Subclass> assignment operators, we still must specify
+ // the LLPointer<Type> operators.
LLPointer<Type>& operator =(const LLPointer<Type>& ptr)
{
LLPointer temp(ptr);