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:
Mark Olesen
2019-11-05 11:10:49 +01:00
committed by Andrew Heather
parent 883752cfb9
commit b0c88dff58
65 changed files with 391 additions and 210 deletions

View File

@ -89,19 +89,16 @@ Foam::CLASSNAME::~CLASSNAME()
void Foam::CLASSNAME::operator=(const CLASSNAME& rhs)
{
// Check for assignment to self
if (this == &rhs)
{
FatalErrorInFunction
<< "Attempted assignment to self"
<< abort(FatalError);
return; // Self-assignment is a no-op
}
}
// * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// ************************************************************************* //