mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: reset tmp via assignment from literal nullptr (#1775)
- previously this was marked as '= delete' for consistency with assignment from an empty pointer being a runtime error. However, these can be considered semantically different and it makes sense to permit this as equivalent to reset(nullptr). This change does not break existing code since the operator was previously unavailable (deleted). STYLE: refactor tmp operator=(T*) - delegate to reset() after initial checks
This commit is contained in:
@ -255,9 +255,8 @@ public:
|
||||
// Fatal for a null pointer, or when the pointer is non-unique.
|
||||
inline void operator=(T* p);
|
||||
|
||||
//- No assignment from literal nullptr.
|
||||
// Consistent with run-time check for nullptr on assignment.
|
||||
void operator=(std::nullptr_t) = delete;
|
||||
//- Reset via assignment from literal nullptr
|
||||
inline void operator=(std::nullptr_t) noexcept;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -464,8 +464,6 @@ inline void Foam::tmp<T>::operator=(tmp<T>&& other) noexcept
|
||||
template<class T>
|
||||
inline void Foam::tmp<T>::operator=(T* p)
|
||||
{
|
||||
clear();
|
||||
|
||||
if (!p)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
@ -480,8 +478,14 @@ inline void Foam::tmp<T>::operator=(T* p)
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
ptr_ = p;
|
||||
type_ = PTR;
|
||||
reset(p);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::tmp<T>::operator=(std::nullptr_t) noexcept
|
||||
{
|
||||
reset(nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -234,9 +234,8 @@ public:
|
||||
// Fatal for a null pointer
|
||||
inline void operator=(T* p);
|
||||
|
||||
//- No assignment from literal nullptr.
|
||||
// Consistent with run-time check for nullptr on assignment.
|
||||
void operator=(std::nullptr_t) = delete;
|
||||
//- Reset via assignment from literal nullptr
|
||||
inline void operator=(std::nullptr_t) noexcept;
|
||||
|
||||
//- Conversion to tmp - releases pointer or copies reference
|
||||
inline operator tmp<T>();
|
||||
|
||||
@ -414,8 +414,6 @@ inline void Foam::tmpNrc<T>::operator=(tmpNrc<T>&& other) noexcept
|
||||
template<class T>
|
||||
inline void Foam::tmpNrc<T>::operator=(T* p)
|
||||
{
|
||||
clear();
|
||||
|
||||
if (!p)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
@ -423,8 +421,14 @@ inline void Foam::tmpNrc<T>::operator=(T* p)
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
ptr_ = p;
|
||||
type_ = PTR;
|
||||
reset(p);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::tmpNrc<T>::operator=(std::nullptr_t) noexcept
|
||||
{
|
||||
reset(nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user