mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: simpler, more consistent checks for tmp validity (#1775)
- Previously considered to be valid() if it was any reference (null or non-null) or a non-null pointer. This appears to be a holdover from old code (pre-2015) where reinterpret_cast<..>(0) was used instead of the NullObject. A reference via a null pointer isn't really possible anywhere. Even for things like labelList::null(), they now use the NullObject, which has a non-zero memory location. - now simply check for a non-zero memory address. Regardless of pointer or referenced object.
This commit is contained in:
@ -160,11 +160,11 @@ public:
|
|||||||
|
|
||||||
// Query
|
// Query
|
||||||
|
|
||||||
//- True if a null managed pointer
|
//- True if a null pointer/reference
|
||||||
bool empty() const noexcept { return !ptr_ && type_ == PTR; }
|
bool empty() const noexcept { return !ptr_; }
|
||||||
|
|
||||||
//- True for non-null managed pointer or an object reference
|
//- True for non-null pointer/reference
|
||||||
bool valid() const noexcept { return ptr_ || type_ == CREF; }
|
bool valid() const noexcept { return ptr_; }
|
||||||
|
|
||||||
//- True if this is a managed pointer (not a reference)
|
//- True if this is a managed pointer (not a reference)
|
||||||
bool isTmp() const noexcept { return type_ == PTR; }
|
bool isTmp() const noexcept { return type_ == PTR; }
|
||||||
@ -241,8 +241,8 @@ public:
|
|||||||
// Fatal for a null managed pointer or if the object is const.
|
// Fatal for a null managed pointer or if the object is const.
|
||||||
inline T* operator->();
|
inline T* operator->();
|
||||||
|
|
||||||
//- Non-null managed pointer or an object reference : valid()
|
//- Non-null pointer/reference : valid()
|
||||||
explicit operator bool() const noexcept { return ptr_ ||type_ == CREF; }
|
explicit operator bool() const noexcept { return ptr_; }
|
||||||
|
|
||||||
//- Transfer ownership of the managed pointer.
|
//- Transfer ownership of the managed pointer.
|
||||||
// Fatal for a null managed pointer or if the object is const.
|
// Fatal for a null managed pointer or if the object is const.
|
||||||
|
|||||||
@ -139,11 +139,11 @@ public:
|
|||||||
|
|
||||||
// Query
|
// Query
|
||||||
|
|
||||||
//- True if a null managed pointer
|
//- True if a null pointer/reference
|
||||||
bool empty() const noexcept { return !ptr_ && type_ == PTR; }
|
bool empty() const noexcept { return !ptr_; }
|
||||||
|
|
||||||
//- True for non-null managed pointer or an object reference
|
//- True for non-null pointer/reference
|
||||||
bool valid() const noexcept { return ptr_ || type_ == CREF; }
|
bool valid() const noexcept { return ptr_; }
|
||||||
|
|
||||||
//- True if this is a managed pointer (not a reference)
|
//- True if this is a managed pointer (not a reference)
|
||||||
bool isTmp() const noexcept { return type_ == PTR; }
|
bool isTmp() const noexcept { return type_ == PTR; }
|
||||||
@ -220,8 +220,8 @@ public:
|
|||||||
// Fatal for a null managed pointer or if the object is const.
|
// Fatal for a null managed pointer or if the object is const.
|
||||||
inline T* operator->();
|
inline T* operator->();
|
||||||
|
|
||||||
//- Non-null managed pointer or an object reference : valid()
|
//- Non-null pointer/reference : valid()
|
||||||
explicit operator bool() const noexcept { return ptr_ ||type_ == CREF; }
|
explicit operator bool() const noexcept { return ptr_; }
|
||||||
|
|
||||||
//- Transfer ownership of the managed pointer.
|
//- Transfer ownership of the managed pointer.
|
||||||
// Fatal for a null managed pointer or if the object is const.
|
// Fatal for a null managed pointer or if the object is const.
|
||||||
|
|||||||
Reference in New Issue
Block a user