mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Make constructors explicit if they could lead to unintended implicit conversion
This commit is contained in:
@@ -68,7 +68,7 @@ template<typename MatrixType,int _Direction> class Homogeneous
|
||||
typedef MatrixBase<Homogeneous> Base;
|
||||
EIGEN_DENSE_PUBLIC_INTERFACE(Homogeneous)
|
||||
|
||||
inline Homogeneous(const MatrixType& matrix)
|
||||
explicit inline Homogeneous(const MatrixType& matrix)
|
||||
: m_matrix(matrix)
|
||||
{}
|
||||
|
||||
@@ -128,7 +128,7 @@ inline typename MatrixBase<Derived>::HomogeneousReturnType
|
||||
MatrixBase<Derived>::homogeneous() const
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
|
||||
return derived();
|
||||
return HomogeneousReturnType(derived());
|
||||
}
|
||||
|
||||
/** \geometry_module
|
||||
@@ -143,7 +143,7 @@ template<typename ExpressionType, int Direction>
|
||||
inline Homogeneous<ExpressionType,Direction>
|
||||
VectorwiseOp<ExpressionType,Direction>::homogeneous() const
|
||||
{
|
||||
return _expression();
|
||||
return HomogeneousReturnType(_expression());
|
||||
}
|
||||
|
||||
/** \geometry_module
|
||||
@@ -323,7 +323,7 @@ struct unary_evaluator<Homogeneous<ArgType,Direction>, IndexBased>
|
||||
typedef evaluator<XprType> type;
|
||||
typedef evaluator<XprType> nestedType;
|
||||
|
||||
unary_evaluator(const XprType& op)
|
||||
explicit unary_evaluator(const XprType& op)
|
||||
: Base(), m_temp(op)
|
||||
{
|
||||
::new (static_cast<Base*>(this)) Base(m_temp);
|
||||
|
||||
@@ -251,7 +251,7 @@ public:
|
||||
inline Quaternion(const Scalar& w, const Scalar& x, const Scalar& y, const Scalar& z) : m_coeffs(x, y, z, w){}
|
||||
|
||||
/** Constructs and initialize a quaternion from the array data */
|
||||
inline Quaternion(const Scalar* data) : m_coeffs(data) {}
|
||||
explicit inline Quaternion(const Scalar* data) : m_coeffs(data) {}
|
||||
|
||||
/** Copy constructor */
|
||||
template<class Derived> EIGEN_STRONG_INLINE Quaternion(const QuaternionBase<Derived>& other) { this->Base::operator=(other); }
|
||||
@@ -351,7 +351,7 @@ class Map<const Quaternion<_Scalar>, _Options >
|
||||
* \code *coeffs == {x, y, z, w} \endcode
|
||||
*
|
||||
* If the template parameter _Options is set to #Aligned, then the pointer coeffs must be aligned. */
|
||||
EIGEN_STRONG_INLINE Map(const Scalar* coeffs) : m_coeffs(coeffs) {}
|
||||
explicit EIGEN_STRONG_INLINE Map(const Scalar* coeffs) : m_coeffs(coeffs) {}
|
||||
|
||||
inline const Coefficients& coeffs() const { return m_coeffs;}
|
||||
|
||||
@@ -388,7 +388,7 @@ class Map<Quaternion<_Scalar>, _Options >
|
||||
* \code *coeffs == {x, y, z, w} \endcode
|
||||
*
|
||||
* If the template parameter _Options is set to #Aligned, then the pointer coeffs must be aligned. */
|
||||
EIGEN_STRONG_INLINE Map(Scalar* coeffs) : m_coeffs(coeffs) {}
|
||||
explicit EIGEN_STRONG_INLINE Map(Scalar* coeffs) : m_coeffs(coeffs) {}
|
||||
|
||||
inline Coefficients& coeffs() { return m_coeffs; }
|
||||
inline const Coefficients& coeffs() const { return m_coeffs; }
|
||||
|
||||
@@ -59,7 +59,7 @@ protected:
|
||||
public:
|
||||
|
||||
/** Construct a 2D counter clock wise rotation from the angle \a a in radian. */
|
||||
inline Rotation2D(const Scalar& a) : m_angle(a) {}
|
||||
explicit inline Rotation2D(const Scalar& a) : m_angle(a) {}
|
||||
|
||||
/** \returns the rotation angle */
|
||||
inline Scalar angle() const { return m_angle; }
|
||||
|
||||
Reference in New Issue
Block a user