Skip to content

Make various Legacy classes Nothrow_copyable #19102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/base/inc/TObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ class TObject {
public:

TObject();
TObject(const TObject &object);
TObject &operator=(const TObject &rhs);
TObject(const TObject &object) noexcept;
TObject &operator=(const TObject &rhs) noexcept;
virtual ~TObject();

virtual void AppendPad(Option_t *option="");
Expand Down Expand Up @@ -272,7 +272,7 @@ inline TObject::TObject() : fBits(kNotDeleted) // Need to leave fUniqueID unset
////////////////////////////////////////////////////////////////////////////////
/// TObject copy ctor.

inline TObject::TObject(const TObject &obj)
inline TObject::TObject(const TObject &obj) noexcept
{
fBits = obj.fBits;

Expand All @@ -296,7 +296,7 @@ inline TObject::TObject(const TObject &obj)
////////////////////////////////////////////////////////////////////////////////
/// TObject assignment operator.

inline TObject &TObject::operator=(const TObject &rhs)
inline TObject &TObject::operator=(const TObject &rhs) noexcept
{
if (R__likely(this != &rhs)) {
fUniqueID = rhs.fUniqueID; // when really unique don't copy
Expand Down
2 changes: 1 addition & 1 deletion math/physics/inc/TLorentzRotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TLorentzRotationRow {
TLorentzRotation(const TRotation &);
// Constructor for 3d rotations.

TLorentzRotation(const TLorentzRotation &);
TLorentzRotation(const TLorentzRotation &) noexcept;
// Copy constructor.

TLorentzRotation(Double_t, Double_t, Double_t);
Expand Down
10 changes: 5 additions & 5 deletions math/physics/inc/TLorentzVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class TLorentzVector : public TObject {
TLorentzVector(const TVector3 & vector3, Double_t t);
// Constructor giving a 3-Vector and a time component.

TLorentzVector(const TLorentzVector & lorentzvector);
TLorentzVector(const TLorentzVector & lorentzvector) noexcept;
// Copy constructor.

~TLorentzVector() override{};
~TLorentzVector() override = default;
// Destructor

// inline operator TVector3 () const;
Expand Down Expand Up @@ -128,7 +128,7 @@ class TLorentzVector : public TObject {
inline Double_t & operator [] (int i);
// Set components by index.

inline TLorentzVector & operator = (const TLorentzVector &);
inline TLorentzVector & operator = (const TLorentzVector &) noexcept;
// Assignment.

inline TLorentzVector operator + (const TLorentzVector &) const;
Expand Down Expand Up @@ -366,7 +366,7 @@ inline void TLorentzVector::GetXYZT(Float_t *carray) const{
inline Double_t & TLorentzVector::operator [] (int i) { return (*this)(i); }
inline Double_t TLorentzVector::operator [] (int i) const { return (*this)(i); }

inline TLorentzVector &TLorentzVector::operator = (const TLorentzVector & q) {
inline TLorentzVector &TLorentzVector::operator = (const TLorentzVector & q) noexcept {
fP = q.Vect();
fE = q.T();
return *this;
Expand Down Expand Up @@ -620,7 +620,7 @@ inline TLorentzVector::TLorentzVector(const Float_t * x0)
inline TLorentzVector::TLorentzVector(const TVector3 & p, Double_t e)
: fP(p), fE(e) {}

inline TLorentzVector::TLorentzVector(const TLorentzVector & p) : TObject(p)
inline TLorentzVector::TLorentzVector(const TLorentzVector & p) noexcept : TObject(p)
, fP(p.Vect()), fE(p.T()) {}


Expand Down
6 changes: 3 additions & 3 deletions math/physics/inc/TQuaternion.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TQuaternion : public TObject {
TQuaternion(const Float_t *);
// Constructors from an array : 0 to 2 = vector part, 3 = real part

TQuaternion(const TQuaternion &);
TQuaternion(const TQuaternion &) noexcept;
// The copy constructor.

~TQuaternion() override;
Expand Down Expand Up @@ -60,7 +60,7 @@ class TQuaternion : public TObject {
TQuaternion operator/(Double_t real) const;

// ---------------- vector to quaternion algebra
inline TQuaternion& operator=(const TVector3& );
inline TQuaternion& operator=(const TVector3& ) noexcept;
inline Bool_t operator == (const TVector3&) const;
inline Bool_t operator != (const TVector3&) const;
inline TQuaternion& operator+=(const TVector3 &vector);
Expand Down Expand Up @@ -200,7 +200,7 @@ inline Bool_t TQuaternion::operator != (const TVector3& V) const {
return (fVectorPart != V || fRealPart != 0) ? kTRUE : kFALSE;
}

inline TQuaternion& TQuaternion::operator=(const TVector3& vect) {
inline TQuaternion& TQuaternion::operator=(const TVector3& vect) noexcept {
fRealPart = 0;
fVectorPart.SetXYZ(vect.X(),vect.Y(),vect.Z());
return *this;
Expand Down
4 changes: 2 additions & 2 deletions math/physics/inc/TVector2.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ class TVector2 : public TObject {
typedef Double_t Scalar; // to be able to use it with the ROOT::Math::VectorUtil functions

TVector2 ();
TVector2 (const TVector2&) = default;
TVector2 (const TVector2&) noexcept = default;
TVector2 (Double_t *s);
TVector2 (Double_t x0, Double_t y0);
~TVector2() override;
~TVector2() override = default;
// ****** unary operators

TVector2& operator = (TVector2 const & v);
Expand Down
6 changes: 3 additions & 3 deletions math/physics/inc/TVector3.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class TVector3 : public TObject {
TVector3(const Float_t *);
// Constructors from an array

TVector3(const TVector3 &);
TVector3(const TVector3 &) noexcept;
// The copy constructor.

~TVector3() override {};
~TVector3() override = default;
// Destructor

Double_t operator () (int) const;
Expand Down Expand Up @@ -247,7 +247,7 @@ inline void TVector3::GetXYZ(Float_t *carray) const {
inline TVector3::TVector3()
: fX(0.0), fY(0.0), fZ(0.0) {}

inline TVector3::TVector3(const TVector3 & p) : TObject(p),
inline TVector3::TVector3(const TVector3 & p) noexcept : TObject(p),
fX(p.fX), fY(p.fY), fZ(p.fZ) {}

inline TVector3::TVector3(Double_t xx, Double_t yy, Double_t zz)
Expand Down
2 changes: 1 addition & 1 deletion math/physics/src/TLorentzRotation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ TLorentzRotation::TLorentzRotation(const TRotation & r)
fzx(r.ZX()), fzy(r.ZY()), fzz(r.ZZ()), fzt(0.0),
ftx(0.0), fty(0.0), ftz(0.0), ftt(1.0) {}

TLorentzRotation::TLorentzRotation(const TLorentzRotation & r) : TObject(r),
TLorentzRotation::TLorentzRotation(const TLorentzRotation & r) noexcept : TObject(r),
fxx(r.fxx), fxy(r.fxy), fxz(r.fxz), fxt(r.fxt),
fyx(r.fyx), fyy(r.fyy), fyz(r.fyz), fyt(r.fyt),
fzx(r.fzx), fzy(r.fzy), fzz(r.fzz), fzt(r.fzt),
Expand Down
2 changes: 1 addition & 1 deletion math/physics/src/TQuaternion.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ ClassImp(TQuaternion);
/****************** CONSTRUCTORS ****************************************************/
////////////////////////////////////////////////////////////////////////////////

TQuaternion::TQuaternion(const TQuaternion & q) : TObject(q),
TQuaternion::TQuaternion(const TQuaternion & q) noexcept : TObject(q),
fRealPart(q.fRealPart), fVectorPart(q.fVectorPart) {}

TQuaternion::TQuaternion(const TVector3 & vect, Double_t real)
Expand Down
5 changes: 0 additions & 5 deletions math/physics/src/TVector2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ TVector2::TVector2(Double_t x0, Double_t y0)
fY = y0;
}

////////////////////////////////////////////////////////////////////////////////

TVector2::~TVector2()
{
}

////////////////////////////////////////////////////////////////////////////////
/// Return modulo of this vector
Expand Down
7 changes: 5 additions & 2 deletions test/TestVectors.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ int TestVectors()
int TestVector3() {

// test constructors:
static_assert(std::is_nothrow_copy_constructible_v<TVector3>);
static_assert(std::is_nothrow_copy_constructible_v<TVector2>);
static_assert(std::is_nothrow_copy_constructible_v<TLorentzRotation>);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
Other potential checks you coud add:

static_assert(std::is_nothrow_move_constructible_v);
static_assert(std::is_trivially_move_constructible_v);
static_assert(std::is_nothrow_move_assignable_v);
static_assert(std::is_trivially_move_assignable_v);
static_assert(std::is_trivially_copyable_v);
static_assert(std::is_trivially_destructible_v);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These cannot be trivially anything because they depend on TObject.

TVector3 d0; assert( test(d0, 0.0, 0.0, 0.0, DEPS) );
TVector3 f0; assert( test(f0, 0.0, 0.0, 0.0, FEPS) );
Expand Down Expand Up @@ -310,7 +313,7 @@ int TestVector3() {


int TestLorentzVector() {

static_assert(std::is_nothrow_copy_constructible_v<TLorentzVector>);
TVector3 f3x(1.0), f3y(0.0, 1.0), f3z(0.0, 0.0, 1.0);
TVector3 d30, d3x(1.0), d3y(0.0, 1.0), d3z(0.0, 0.0, 1.0);

Expand Down Expand Up @@ -491,7 +494,7 @@ int TestLorentzVector() {
//typedef TVector3 Vector;

int TestRotation() {

static_assert(std::is_nothrow_copy_constructible_v<TRotation>);
int i,k;
double angA=TMath::Pi()/3, angB=TMath::Pi()/4, angC=TMath::Pi()/6;
double cosA=TMath::Cos(angA), sinA=TMath::Sin(angA);
Expand Down