mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: treat self-assignment as no-op instead of a Fatal (#1473)
- this can help if using std algorithms that return a const reference such as std::min() does.
This commit is contained in:
committed by
Andrew Heather
parent
883752cfb9
commit
b0c88dff58
@ -232,6 +232,11 @@ void Foam::DictionaryBase<IDLListType, T>::transfer
|
||||
DictionaryBase<IDLListType, T>& dict
|
||||
)
|
||||
{
|
||||
if (this == &dict)
|
||||
{
|
||||
return; // Self-assignment is a no-op
|
||||
}
|
||||
|
||||
IDLListType::transfer(dict);
|
||||
hashedTs_.transfer(dict.hashedTs_);
|
||||
}
|
||||
@ -247,9 +252,7 @@ void Foam::DictionaryBase<IDLListType, T>::operator=
|
||||
{
|
||||
if (this == &dict)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "attempted assignment to self"
|
||||
<< abort(FatalError);
|
||||
return; // Self-assignment is a no-op
|
||||
}
|
||||
|
||||
IDLListType::operator=(dict);
|
||||
|
||||
Reference in New Issue
Block a user