mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 09:03:34 +08:00
Make all array constructors explicit (#99)
* Make all array constructors explicit to avoid accidental implicit casts like e.g. Vector3f v = 0; assigning nullpointer content.
This commit is contained in:
committed by
Julian Kent
parent
7b34c1c51d
commit
740324cf1e
@@ -37,7 +37,7 @@ public:
|
||||
*
|
||||
* @param data_ array
|
||||
*/
|
||||
AxisAngle(const Type data_[3]) :
|
||||
explicit AxisAngle(const Type data_[3]) :
|
||||
Vector<Type, 3>(data_)
|
||||
{
|
||||
}
|
||||
|
||||
+10
-1
@@ -56,7 +56,16 @@ public:
|
||||
*
|
||||
* @param _data pointer to array
|
||||
*/
|
||||
Dcm(const Type *data_) : SquareMatrix<Type, 3>(data_)
|
||||
explicit Dcm(const Type data_[3][3]) : SquareMatrix<Type, 3>(data_)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor from array
|
||||
*
|
||||
* @param _data pointer to array
|
||||
*/
|
||||
explicit Dcm(const Type data_[3*3]) : SquareMatrix<Type, 3>(data_)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -41,12 +41,12 @@ public:
|
||||
// Constructors
|
||||
Matrix() = default;
|
||||
|
||||
Matrix(const Type data_[M*N])
|
||||
explicit Matrix(const Type data_[M*N])
|
||||
{
|
||||
memcpy(_data, data_, sizeof(_data));
|
||||
}
|
||||
|
||||
Matrix(const Type data_[M][N])
|
||||
explicit Matrix(const Type data_[M][N])
|
||||
{
|
||||
memcpy(_data, data_, sizeof(_data));
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
*
|
||||
* @param data_ array
|
||||
*/
|
||||
Quaternion(const Type data_[4]) :
|
||||
explicit Quaternion(const Type data_[4]) :
|
||||
Vector<Type, 4>(data_)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -28,7 +28,12 @@ class SquareMatrix : public Matrix<Type, M, M>
|
||||
public:
|
||||
SquareMatrix() = default;
|
||||
|
||||
SquareMatrix(const Type data_[M][M]) :
|
||||
explicit SquareMatrix(const Type data_[M][M]) :
|
||||
Matrix<Type, M, M>(data_)
|
||||
{
|
||||
}
|
||||
|
||||
explicit SquareMatrix(const Type data_[M*M]) :
|
||||
Matrix<Type, M, M>(data_)
|
||||
{
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
Vector(const Type data_[M]) :
|
||||
explicit Vector(const Type data_[M]) :
|
||||
MatrixM1(data_)
|
||||
{
|
||||
}
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
Vector2(const Type data_[2]) :
|
||||
explicit Vector2(const Type data_[2]) :
|
||||
Vector<Type, 2>(data_)
|
||||
{
|
||||
}
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
Vector3(const Type data_[3]) :
|
||||
explicit Vector3(const Type data_[3]) :
|
||||
Vector<Type, 3>(data_)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user