Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CLHEP
CLHEP
Commits
995e7876
Commit
995e7876
authored
Oct 21, 2019
by
Lynn Garren
Browse files
move constructors added by Evgueni Tcherniaev
parent
7062c532
Changes
19
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
995e7876
2019-10-18 Evgueni Tcherniaev <evgueni.tcherniaev.@cern.ch>
* Vector/Vector/*.h: added move constructor and move assignment
* Geometry/Geometry/*.h: added move constructor and move assignment
==============================
20.06.19 Release CLHEP-2.4.1.2
==============================
...
...
Geometry/Geometry/BasicVector3D.h
View file @
995e7876
...
...
@@ -13,6 +13,7 @@
#define BASIC_VECTOR3D_H
#include
<iosfwd>
#include
<type_traits>
#include
"CLHEP/Geometry/defs.h"
#include
"CLHEP/Vector/ThreeVector.h"
...
...
@@ -52,19 +53,24 @@ namespace HepGeom {
BasicVector3D
(
T
x1
,
T
y1
,
T
z1
)
{
v_
[
0
]
=
x1
;
v_
[
1
]
=
y1
;
v_
[
2
]
=
z1
;
}
/**
* Copy constructor.
* Note: BasicVector3D<double> has constructors
* from BasicVector3D<double> (provided by compiler) and
* from BasicVector3D<float> (defined in this file);
* BasicVector3D<float> has only the last one.
*/
* Copy constructor. */
BasicVector3D
(
const
BasicVector3D
<
T
>
&
)
=
default
;
/**
* Constructor for BasicVector3D<double> from BasicVector3D<float>. */
template
<
typename
U
=
T
,
typename
=
typename
std
::
enable_if
<!
std
::
is_same
<
U
,
float
>
::
value
>::
type
>
BasicVector3D
(
const
BasicVector3D
<
float
>
&
v
)
{
v_
[
0
]
=
v
.
x
();
v_
[
1
]
=
v
.
y
();
v_
[
2
]
=
v
.
z
();
}
/**
* Move constructor. */
BasicVector3D
(
BasicVector3D
<
T
>
&&
)
=
default
;
/**
* Destructor. */
virtual
~
BasicVector3D
()
{}
virtual
~
BasicVector3D
()
=
default
;
// -------------------------
// Interface to "good old C"
...
...
@@ -82,7 +88,7 @@ namespace HepGeom {
* Conversion (cast) to CLHEP::Hep3Vector.
* This operator is needed only for backward compatibility and
* in principle should not exit.
*/
*/
operator
CLHEP
::
Hep3Vector
()
const
{
return
CLHEP
::
Hep3Vector
(
x
(),
y
(),
z
());
}
// -----------------------------
...
...
@@ -92,6 +98,9 @@ namespace HepGeom {
/**
* Assignment. */
BasicVector3D
<
T
>
&
operator
=
(
const
BasicVector3D
<
T
>
&
)
=
default
;
/**
* Move assignment. */
BasicVector3D
<
T
>
&
operator
=
(
BasicVector3D
<
T
>
&&
)
=
default
;
/**
* Addition. */
BasicVector3D
<
T
>
&
operator
+=
(
const
BasicVector3D
<
T
>
&
v
)
{
...
...
@@ -123,36 +132,36 @@ namespace HepGeom {
/**
* Gets components by index. */
T
operator
[](
int
i
)
const
{
return
v_
[
i
];
}
/**
* Sets components by index. */
T
&
operator
()(
int
i
)
{
return
v_
[
i
];
}
/**
* Sets components by index. */
T
&
operator
[](
int
i
)
{
return
v_
[
i
];
}
// ------------------------------------
// Cartesian coordinate system: x, y, z
// ------------------------------------
/**
* Gets x-component in cartesian coordinate system. */
* Gets x-component in cartesian coordinate system. */
T
x
()
const
{
return
v_
[
0
];
}
/**
* Gets y-component in cartesian coordinate system. */
* Gets y-component in cartesian coordinate system. */
T
y
()
const
{
return
v_
[
1
];
}
/**
* Gets z-component in cartesian coordinate system. */
* Gets z-component in cartesian coordinate system. */
T
z
()
const
{
return
v_
[
2
];
}
/**
* Sets x-component in cartesian coordinate system. */
* Sets x-component in cartesian coordinate system. */
void
setX
(
T
a
)
{
v_
[
0
]
=
a
;
}
/**
* Sets y-component in cartesian coordinate system. */
* Sets y-component in cartesian coordinate system. */
void
setY
(
T
a
)
{
v_
[
1
]
=
a
;
}
/**
* Sets z-component in cartesian coordinate system. */
* Sets z-component in cartesian coordinate system. */
void
setZ
(
T
a
)
{
v_
[
2
]
=
a
;
}
/**
...
...
@@ -179,7 +188,7 @@ namespace HepGeom {
T
factor
=
perp
();
if
(
factor
>
0
)
{
factor
=
rh
/
factor
;
v_
[
0
]
*=
factor
;
v_
[
1
]
*=
factor
;
}
}
}
// ------------------------------------------
...
...
@@ -212,10 +221,10 @@ namespace HepGeom {
/**
* Gets r-component in spherical coordinate system */
T
getR
()
const
{
return
r
();
}
/**
/**
* Gets phi-component in spherical coordinate system */
T
getPhi
()
const
{
return
phi
();
}
/**
/**
* Gets theta-component in spherical coordinate system */
T
getTheta
()
const
{
return
theta
();
}
...
...
@@ -225,7 +234,7 @@ namespace HepGeom {
T
factor
=
mag
();
if
(
factor
>
0
)
{
factor
=
ma
/
factor
;
v_
[
0
]
*=
factor
;
v_
[
1
]
*=
factor
;
v_
[
2
]
*=
factor
;
}
}
}
/**
* Sets r-component in spherical coordinate system. */
...
...
@@ -246,7 +255,7 @@ namespace HepGeom {
// ---------------
/**
* Gets pseudo-rapidity: -ln(
std::
tan(theta/2)) */
* Gets pseudo-rapidity: -ln(tan(theta/2)) */
T
pseudoRapidity
()
const
;
/**
* Gets pseudo-rapidity. */
...
...
@@ -299,7 +308,7 @@ namespace HepGeom {
// ---------------
/**
* Returns unit vector parallel to this. */
* Returns unit vector parallel to this. */
BasicVector3D
<
T
>
unit
()
const
{
T
len
=
mag
();
return
(
len
>
0
)
?
...
...
@@ -307,7 +316,7 @@ namespace HepGeom {
}
/**
* Returns orthogonal vector. */
* Returns orthogonal vector. */
BasicVector3D
<
T
>
orthogonal
()
const
{
T
dx
=
x
()
<
0
?
-
x
()
:
x
();
T
dy
=
y
()
<
0
?
-
y
()
:
y
();
...
...
@@ -340,9 +349,9 @@ namespace HepGeom {
};
/*************************************************************************
* *
* *
* Non-member functions for BasicVector3D<float> *
* *
* *
*************************************************************************/
/**
...
...
@@ -428,9 +437,9 @@ namespace HepGeom {
operator
/
(
const
BasicVector3D
<
float
>
&
v
,
double
a
)
{
return
BasicVector3D
<
float
>
(
v
.
x
()
/
static_cast
<
float
>
(
a
),
v
.
y
()
/
static_cast
<
float
>
(
a
),
v
.
z
()
/
static_cast
<
float
>
(
a
));
}
/**
* Comparison of two vectors for equality.
* Comparison of two vectors for equality.
* @relates BasicVector3D
*/
inline
bool
...
...
@@ -439,7 +448,7 @@ namespace HepGeom {
}
/**
* Comparison of two vectors for inequality.
* Comparison of two vectors for inequality.
* @relates BasicVector3D
*/
inline
bool
...
...
@@ -448,9 +457,9 @@ namespace HepGeom {
}
/*************************************************************************
* *
* *
* Non-member functions for BasicVector3D<double> *
* *
* *
*************************************************************************/
/**
...
...
@@ -536,9 +545,9 @@ namespace HepGeom {
operator
/
(
const
BasicVector3D
<
double
>
&
v
,
double
a
)
{
return
BasicVector3D
<
double
>
(
v
.
x
()
/
a
,
v
.
y
()
/
a
,
v
.
z
()
/
a
);
}
/**
* Comparison of two vectors for equality.
* Comparison of two vectors for equality.
* @relates BasicVector3D
*/
inline
bool
...
...
@@ -548,7 +557,7 @@ namespace HepGeom {
}
/**
* Comparison of two vectors for inequality.
* Comparison of two vectors for inequality.
* @relates BasicVector3D
*/
inline
bool
...
...
Geometry/Geometry/Normal3D.h
View file @
995e7876
...
...
@@ -45,7 +45,7 @@ namespace HepGeom {
public:
/**
* Default constructor. */
Normal3D
()
{}
Normal3D
()
=
default
;
/**
* Constructor from three numbers. */
...
...
@@ -58,7 +58,11 @@ namespace HepGeom {
/**
* Copy constructor. */
Normal3D
(
const
Normal3D
<
float
>
&
v
)
:
BasicVector3D
<
float
>
(
v
)
{}
Normal3D
(
const
Normal3D
<
float
>
&
)
=
default
;
/**
* Move constructor. */
Normal3D
(
Normal3D
<
float
>
&&
)
=
default
;
/**
* Constructor from BasicVector3D<float>. */
...
...
@@ -66,20 +70,23 @@ namespace HepGeom {
/**
* Destructor. */
~
Normal3D
()
{}
~
Normal3D
()
=
default
;
/**
* Assignment. */
Normal3D
<
float
>
&
operator
=
(
const
Normal3D
<
float
>
&
v
)
{
set
(
v
.
x
(),
v
.
y
(),
v
.
z
());
return
*
this
;
}
Normal3D
<
float
>
&
operator
=
(
const
Normal3D
<
float
>
&
)
=
default
;
/**
* Assignment from BasicVector3D<float>. */
Normal3D
<
float
>
&
operator
=
(
const
BasicVector3D
<
float
>
&
v
)
{
set
(
v
.
x
(),
v
.
y
(),
v
.
z
());
return
*
this
;
this
->
BasicVector3D
<
float
>::
operator
=
(
v
);
return
*
this
;
}
/**
* Move assignment. */
Normal3D
<
float
>
&
operator
=
(
Normal3D
<
float
>
&&
)
=
default
;
/**
* Transformation by Transform3D. */
Normal3D
<
float
>
&
transform
(
const
Transform3D
&
m
);
...
...
@@ -103,7 +110,7 @@ namespace HepGeom {
public:
/**
* Default constructor. */
Normal3D
()
{}
Normal3D
()
=
default
;
/**
* Constructor from three numbers. */
...
...
@@ -121,7 +128,11 @@ namespace HepGeom {
/**
* Copy constructor. */
Normal3D
(
const
Normal3D
<
double
>
&
v
)
:
BasicVector3D
<
double
>
(
v
)
{}
Normal3D
(
const
Normal3D
<
double
>
&
)
=
default
;
/**
* Move constructor. */
Normal3D
(
Normal3D
<
double
>
&&
)
=
default
;
/**
* Constructor from BasicVector3D<float>. */
...
...
@@ -133,7 +144,7 @@ namespace HepGeom {
/**
* Destructor. */
~
Normal3D
()
{}
~
Normal3D
()
=
default
;
/**
* Constructor from CLHEP::Hep3Vector.
...
...
@@ -147,27 +158,31 @@ namespace HepGeom {
* Conversion (cast) to CLHEP::Hep3Vector.
* This operator is needed only for backward compatibility and
* in principle should not exit.
*/
*/
operator
CLHEP
::
Hep3Vector
()
const
{
return
CLHEP
::
Hep3Vector
(
x
(),
y
(),
z
());
}
/**
* Assignment. */
Normal3D
<
double
>
&
operator
=
(
const
Normal3D
<
double
>
&
v
)
{
set
(
v
.
x
(),
v
.
y
(),
v
.
z
());
return
*
this
;
}
Normal3D
<
double
>
&
operator
=
(
const
Normal3D
<
double
>
&
)
=
default
;
/**
* Assignment from BasicVector3D<float>. */
Normal3D
<
double
>
&
operator
=
(
const
BasicVector3D
<
float
>
&
v
)
{
set
(
v
.
x
(),
v
.
y
(),
v
.
z
());
return
*
this
;
this
->
BasicVector3D
<
double
>::
operator
=
(
v
);
return
*
this
;
}
/**
* Assignment from BasicVector3D<double>. */
Normal3D
<
double
>
&
operator
=
(
const
BasicVector3D
<
double
>
&
v
)
{
set
(
v
.
x
(),
v
.
y
(),
v
.
z
());
return
*
this
;
this
->
BasicVector3D
<
double
>::
operator
=
(
v
);
return
*
this
;
}
/**
* Move assignment. */
Normal3D
<
double
>
&
operator
=
(
Normal3D
<
double
>
&&
)
=
default
;
/**
* Transformation by Transform3D. */
Normal3D
<
double
>
&
transform
(
const
Transform3D
&
m
);
...
...
Geometry/Geometry/Plane3D.h
View file @
995e7876
...
...
@@ -30,7 +30,7 @@ namespace HepGeom {
class
Plane3D
{
protected:
T
a_
,
b_
,
c_
,
d_
;
public:
/**
* Default constructor - creates plane z=0. */
...
...
@@ -54,23 +54,33 @@ namespace HepGeom {
a_
=
n
.
x
();
b_
=
n
.
y
();
c_
=
n
.
z
();
d_
=
-
n
*
p1
;
}
/** Copy constructor.
* Plane3D<double> has two constructors:
* from Plane3D<double> (provided by compiler) and
* from Plane3D<float> (defined in this file).
* Plane3D<float> has only the last one.
*/
/**
* Copy constructor. */
Plane3D
(
const
Plane3D
<
T
>
&
)
=
default
;
/**
* Constructor for Plane3D<double> from Plane3D<float>. */
template
<
typename
U
=
T
,
typename
=
typename
std
::
enable_if
<!
std
::
is_same
<
U
,
float
>
::
value
>::
type
>
Plane3D
(
const
Plane3D
<
float
>
&
p
)
:
a_
(
p
.
a_
),
b_
(
p
.
b_
),
c_
(
p
.
c_
),
d_
(
p
.
d_
)
{}
/**
* Move constructor. */
Plane3D
(
Plane3D
<
T
>
&&
)
=
default
;
/**
* Destructor. */
~
Plane3D
()
{}
;
~
Plane3D
()
=
default
;
/**
* Assignment. */
Plane3D
<
T
>
&
operator
=
(
const
Plane3D
<
T
>
&
)
=
default
;
/**
* Move assignment. */
Plane3D
<
T
>
&
operator
=
(
Plane3D
<
T
>
&&
)
=
default
;
/**
* Returns the a-coefficient in the plane equation: a*x+b*y+c*z+d=0. */
T
a
()
const
{
return
a_
;
}
...
...
Geometry/Geometry/Point3D.h
View file @
995e7876
...
...
@@ -45,7 +45,7 @@ namespace HepGeom {
public:
/**
* Default constructor. */
Point3D
()
{}
Point3D
()
=
default
;
/**
* Constructor from three numbers. */
...
...
@@ -58,7 +58,11 @@ namespace HepGeom {
/**
* Copy constructor. */
Point3D
(
const
Point3D
<
float
>
&
v
)
:
BasicVector3D
<
float
>
(
v
)
{}
Point3D
(
const
Point3D
<
float
>
&
)
=
default
;
/**
* Move constructor. */
Point3D
(
Point3D
<
float
>
&&
)
=
default
;
/**
* Constructor from BasicVector3D<float>. */
...
...
@@ -66,20 +70,23 @@ namespace HepGeom {
/**
* Destructor. */
~
Point3D
()
{}
~
Point3D
()
=
default
;
/**
* Assignment. */
Point3D
<
float
>
&
operator
=
(
const
Point3D
<
float
>
&
v
)
{
set
(
v
.
x
(),
v
.
y
(),
v
.
z
());
return
*
this
;
}
Point3D
<
float
>
&
operator
=
(
const
Point3D
<
float
>
&
)
=
default
;
/**
* Assignment from BasicVector3D<float>. */
Point3D
<
float
>
&
operator
=
(
const
BasicVector3D
<
float
>
&
v
)
{
set
(
v
.
x
(),
v
.
y
(),
v
.
z
());
return
*
this
;
this
->
BasicVector3D
<
float
>::
operator
=
(
v
);
return
*
this
;
}
/**
* Move assignment. */
Point3D
<
float
>
&
operator
=
(
Point3D
<
float
>
&&
)
=
default
;
/**
* Returns distance to the origin squared. */
float
distance2
()
const
{
return
mag2
();
}
...
...
@@ -124,7 +131,7 @@ namespace HepGeom {
public:
/**
* Default constructor. */
Point3D
()
{}
Point3D
()
=
default
;
/**
* Constructor from three numbers. */
...
...
@@ -142,7 +149,11 @@ namespace HepGeom {
/**
* Copy constructor. */
Point3D
(
const
Point3D
<
double
>
&
v
)
:
BasicVector3D
<
double
>
(
v
)
{}
Point3D
(
const
Point3D
<
double
>
&
)
=
default
;
/**
* Move constructor. */
Point3D
(
Point3D
<
double
>
&&
)
=
default
;
/**
* Constructor from BasicVector3D<float>. */
...
...
@@ -154,7 +165,7 @@ namespace HepGeom {
/**
* Destructor. */
~
Point3D
()
{}
~
Point3D
()
=
default
;
/**
* Constructor from CLHEP::Hep3Vector.
...
...
@@ -168,27 +179,31 @@ namespace HepGeom {
* Conversion (cast) to CLHEP::Hep3Vector.
* This operator is needed only for backward compatibility and
* in principle should not exit.
*/
*/
operator
CLHEP
::
Hep3Vector
()
const
{
return
CLHEP
::
Hep3Vector
(
x
(),
y
(),
z
());
}
/**
* Assignment. */
Point3D
<
double
>
&
operator
=
(
const
Point3D
<
double
>
&
v
)
{
set
(
v
.
x
(),
v
.
y
(),
v
.
z
());
return
*
this
;
}
Point3D
<
double
>
&
operator
=
(
const
Point3D
<
double
>
&
)
=
default
;
/**
* Assignment from BasicVector3D<float>. */
Point3D
<
double
>
&
operator
=
(
const
BasicVector3D
<
float
>
&
v
)
{
set
(
v
.
x
(),
v
.
y
(),
v
.
z
());
return
*
this
;
this
->
BasicVector3D
<
double
>::
operator
=
(
v
);
return
*
this
;
}
/**
* Assignment from BasicVector3D<double>. */
Point3D
<
double
>
&
operator
=
(
const
BasicVector3D
<
double
>
&
v
)
{
set
(
v
.
x
(),
v
.
y
(),
v
.
z
());
return
*
this
;
this
->
BasicVector3D
<
double
>::
operator
=
(
v
);
return
*
this
;
}
/**
* Move assignment. */
Point3D
<
double
>
&
operator
=
(
Point3D
<
double
>
&&
)
=
default
;
/**
* Returns distance to the origin squared. */
double
distance2
()
const
{
return
mag2
();
}
...
...
@@ -224,7 +239,6 @@ namespace HepGeom {
}
/* namespace HepGeom */
#ifdef ENABLE_BACKWARDS_COMPATIBILITY
// backwards compatibility will be enabled ONLY in CLHEP 1.9
#include
"CLHEP/config/CLHEP.h"
...
...
Geometry/Geometry/Transform3D.h
View file @
995e7876
...
...
@@ -61,7 +61,7 @@
// Scalings:
// Scale3D(sx,sy,sz) - general scaling with factors "sx","sy","sz"
// along X, Y and Z;
// Scale3D(s) - scaling with constant factor "s" along all
// Scale3D(s) - scaling with constant factor "s" along all
// directions;
// ScaleX3D(sx) - scale X;
// ScaleY3D(sy) - scale Y;
...
...
@@ -85,7 +85,7 @@
//
// The following table explains how different transformations affect
// point, vector and normal. "+" means affect, "-" means do not affect,
// "*" meas affect but in different way than "+"
// "*" meas affect but in different way than "+"
//
// Point Vector Normal
// -------------+-------+-------+-------
...
...
@@ -110,9 +110,9 @@
// 24.09.96 E.Chernyaev - initial version
//
// 26.02.97 E.Chernyaev
// - added global Identity by request of John Allison
// (to avoid problems with compilation on HP)
// - added getRotation and getTranslation
// - added global Identity by request of John Allison
// (to avoid problems with compilation on HP)
// - added getRotation and getTranslation
//
// 29.01.01 E.Chernyaev - added subscripting
// 11.06.01 E.Chernyaev - added getDecomposition
...
...
@@ -197,7 +197,7 @@ namespace HepGeom {
* Global identity transformation. */
static
const
Transform3D
Identity
;
// Helper class for implemention of C-style subscripting r[i][j]
// Helper class for implemention of C-style subscripting r[i][j]
class
Transform3D_row
{
public:
inline
Transform3D_row
(
const
Transform3D
&
,
int
);
...
...
@@ -213,7 +213,7 @@ namespace HepGeom {
:
xx_
(
1
),
xy_
(
0
),
xz_
(
0
),
dx_
(
0
),
yx_
(
0
),
yy_
(
1
),
yz_
(
0
),
dy_
(
0
),
zx_
(
0
),
zy_
(
0
),
zz_
(
1
),
dz_
(
0
)
{}
/**
* Constructor: rotation and then translation. */
inline
Transform3D
(
const
CLHEP
::
HepRotation
&
mt
,
const
CLHEP
::
Hep3Vector
&
v
);
...
...
@@ -229,21 +229,27 @@ namespace HepGeom {
/**
* Copy constructor. */
Transform3D
(
const
Transform3D
&
mt
)
:
xx_
(
mt
.
xx_
),
xy_
(
mt
.
xy_
),
xz_
(
mt
.
xz_
),
dx_
(
mt
.
dx_
),
yx_
(
mt
.
yx_
),
yy_
(
mt
.
yy_
),
yz_
(
mt
.
yz_
),
dy_
(
mt
.
dy_
),
zx_
(
mt
.
zx_
),
zy_
(
mt
.
zy_
),
zz_
(
mt
.
zz_
),
dz_
(
mt
.
dz_
)
{}
Transform3D
(
const
Transform3D
&
mt
)
=
default
;
/**
* Destructor.
* Virtual for now as some persistency mechanism needs that,
* in future releases this might go away again.
*/
~
Transform3D
()
{
/* nop */
}
* Move constructor. */
Transform3D
(
Transform3D
&&
mt
)
=
default
;
/**
* Destructor. */
~
Transform3D
()
=
default
;
/**
* Assignment. */
Transform3D
&
operator
=
(
const
Transform3D
&
mt
)
=
default
;
/**
* Move assignment. */
Transform3D
&
operator
=
(
Transform3D
&&
mt
)
=
default
;
/**
* Returns object of the helper class for C-style subscripting r[i][j] */
inline
const
Transform3D_row
operator
[]
(
int
)
const
;
inline
const
Transform3D_row
operator
[]
(
int
)
const
;
/** Fortran-style subscripting: returns (i,j) element of the matrix. */
double
operator
()
(
int
,
int
)
const
;
...
...
@@ -266,7 +272,7 @@ namespace HepGeom {
/**
* Gets yz-element of the transformation matrix. */
double
yz
()
const
{
return
yz_
;
}
/**
/**
* Gets zx-element of the transformation matrix. */
double
zx
()
const
{
return
zx_
;
}
/**
...
...
@@ -284,30 +290,21 @@ namespace HepGeom {
/**
* Gets dz-element of the transformation matrix. */
double
dz
()
const
{
return
dz_
;
}
/**
* Assignment. */
Transform3D
&
operator
=
(
const
Transform3D
&
mt
)
{
xx_
=
mt
.
xx_
;
xy_
=
mt
.
xy_
;
xz_
=
mt
.
xz_
;
dx_
=
mt
.
dx_
;
yx_
=
mt
.
yx_
;
yy_
=
mt
.
yy_
;
yz_
=
mt
.
yz_
;
dy_
=
mt
.
dy_
;