cleanup: remove copy contructors when the compiler is able to generate a satisfactory

default copy constructor; remove useless static_cast's; some misc cleanup.
This commit is contained in:
Benoit Jacob
2007-12-31 13:29:51 +00:00
parent 86220784b6
commit 42f6590bb2
21 changed files with 53 additions and 81 deletions

View File

@@ -64,10 +64,6 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block
&& startCol >= 0 && BlockCols >= 1 && startCol + BlockCols <= matrix.cols());
}
Block(const Block& other)
: m_matrix(other.m_matrix),
m_startRow(other.m_startRow), m_startCol(other.m_startCol) {}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block)
private:

View File

@@ -56,9 +56,6 @@ template<typename NewScalar, typename MatrixType> class Cast : NoOperatorEquals,
Cast(const MatRef& matrix) : m_matrix(matrix) {}
Cast(const Cast& other)
: m_matrix(other.m_matrix) {}
private:
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
@@ -78,7 +75,7 @@ template<typename NewScalar, typename MatrixType> class Cast : NoOperatorEquals,
/** \returns an expression of *this with the \a Scalar type casted to
* \a NewScalar.
*
* \param NewScalar the type we are casting the scalars to
* The template parameter \a NewScalar is the type we are casting the scalars to.
*
* Example: \include MatrixBase_cast.cpp
* Output: \verbinclude MatrixBase_cast.out
@@ -90,7 +87,7 @@ template<typename NewScalar>
const Cast<NewScalar, Derived>
MatrixBase<Scalar, Derived>::cast() const
{
return Cast<NewScalar, Derived>(static_cast<const Derived*>(this)->ref());
return Cast<NewScalar, Derived>(ref());
}
#endif // EIGEN_CAST_H

View File

@@ -60,9 +60,6 @@ template<typename MatrixType> class Column
assert(col >= 0 && col < matrix.cols());
}
Column(const Column& other)
: m_matrix(other.m_matrix), m_col(other.m_col) {}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Column)
private:
@@ -89,8 +86,8 @@ template<typename MatrixType> class Column
/** \returns an expression of the \a i-th column of *this. Note that the numbering starts at 0.
*
* Example: \include MatrixBase_column.cpp
* Output: \verbinclude MatrixBase_column.out
* Example: \include MatrixBase_col.cpp
* Output: \verbinclude MatrixBase_col.out
*
* \sa row(), class Column */
template<typename Scalar, typename Derived>

View File

@@ -48,9 +48,6 @@ template<typename MatrixType> class Conjugate : NoOperatorEquals,
Conjugate(const MatRef& matrix) : m_matrix(matrix) {}
Conjugate(const Conjugate& other)
: m_matrix(other.m_matrix) {}
private:
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
@@ -75,7 +72,7 @@ template<typename Scalar, typename Derived>
const Conjugate<Derived>
MatrixBase<Scalar, Derived>::conjugate() const
{
return Conjugate<Derived>(static_cast<const Derived*>(this)->ref());
return Conjugate<Derived>(ref());
}
/** \returns an expression of the adjoint (i.e. conjugate transpose) of *this.

View File

@@ -48,8 +48,6 @@ template<typename MatrixType> class DiagonalCoeffs
DiagonalCoeffs(const MatRef& matrix) : m_matrix(matrix) {}
DiagonalCoeffs(const DiagonalCoeffs& other) : m_matrix(other.m_matrix) {}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DiagonalCoeffs)
private:

View File

@@ -41,9 +41,6 @@ template<typename Lhs, typename Rhs> class Difference : NoOperatorEquals,
assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
}
Difference(const Difference& other)
: m_lhs(other.m_lhs), m_rhs(other.m_rhs) {}
private:
static const int _RowsAtCompileTime = Lhs::RowsAtCompileTime,
_ColsAtCompileTime = Rhs::ColsAtCompileTime;

View File

@@ -64,11 +64,6 @@ template<typename MatrixType> class DynBlock
&& startCol >= 0 && blockCols >= 1 && startCol + blockCols <= matrix.cols());
}
DynBlock(const DynBlock& other)
: m_matrix(other.m_matrix),
m_startRow(other.m_startRow), m_startCol(other.m_startCol),
m_blockRows(other.m_blockRows), m_blockCols(other.m_blockCols) {}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DynBlock)
private:

View File

@@ -32,14 +32,7 @@ template<typename MatrixType> class Map
public:
typedef typename MatrixType::Scalar Scalar;
friend class MatrixBase<Scalar, Map<MatrixType> >;
Map(const Scalar* data, int rows, int cols) : m_data(data), m_rows(rows), m_cols(cols)
{
assert(rows > 0 && cols > 0);
}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
private:
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
@@ -65,6 +58,17 @@ template<typename MatrixType> class Map
else // RowDominant
return const_cast<Scalar*>(m_data)[col + row * m_cols];
}
public:
Map(const Scalar* data, int rows, int cols) : m_data(data), m_rows(rows), m_cols(cols)
{
assert(rows > 0
&& (_RowsAtCompileTime == Dynamic || _RowsAtCompileTime == rows)
&& cols > 0
&& (_ColsAtCompileTime == Dynamic || _ColsAtCompileTime == cols));
}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
protected:
const Scalar* m_data;

View File

@@ -34,7 +34,6 @@ template<typename MatrixType> class MatrixRef
friend class MatrixBase<Scalar, MatrixRef>;
MatrixRef(const MatrixType& matrix) : m_matrix(matrix) {}
MatrixRef(const MatrixRef& other) : m_matrix(other.m_matrix) {}
~MatrixRef() {}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixRef)

View File

@@ -54,9 +54,6 @@ template<typename MatrixType> class Minor
&& col >= 0 && col < matrix.cols());
}
Minor(const Minor& other)
: m_matrix(other.m_matrix), m_row(other.m_row), m_col(other.m_col) {}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor)
private:

View File

@@ -32,12 +32,7 @@ template<typename MatrixType> class Ones : NoOperatorEquals,
public:
typedef typename MatrixType::Scalar Scalar;
friend class MatrixBase<Scalar, Ones<MatrixType> >;
Ones(int rows, int cols) : m_rows(rows), m_cols(cols)
{
assert(rows > 0 && cols > 0);
}
private:
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
@@ -50,6 +45,15 @@ template<typename MatrixType> class Ones : NoOperatorEquals,
{
return static_cast<Scalar>(1);
}
public:
Ones(int rows, int cols) : m_rows(rows), m_cols(cols)
{
assert(rows > 0
&& (_RowsAtCompileTime == Dynamic || _RowsAtCompileTime == rows)
&& cols > 0
&& (_ColsAtCompileTime == Dynamic || _ColsAtCompileTime == cols));
}
protected:
int m_rows, m_cols;

View File

@@ -36,9 +36,6 @@ template<typename MatrixType> class Opposite : NoOperatorEquals,
Opposite(const MatRef& matrix) : m_matrix(matrix) {}
Opposite(const Opposite& other)
: m_matrix(other.m_matrix) {}
private:
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
@@ -60,7 +57,7 @@ template<typename Scalar, typename Derived>
const Opposite<Derived>
MatrixBase<Scalar, Derived>::operator-() const
{
return Opposite<Derived>(static_cast<const Derived*>(this)->ref());
return Opposite<Derived>(ref());
}
#endif // EIGEN_OPPOSITE_H

View File

@@ -75,9 +75,6 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
assert(lhs.cols() == rhs.rows());
}
Product(const Product& other)
: m_lhs(other.m_lhs), m_rhs(other.m_rhs) {}
private:
static const int _RowsAtCompileTime = Lhs::RowsAtCompileTime,
_ColsAtCompileTime = Rhs::ColsAtCompileTime;

View File

@@ -32,12 +32,7 @@ template<typename MatrixType> class Random : NoOperatorEquals,
public:
typedef typename MatrixType::Scalar Scalar;
friend class MatrixBase<Scalar, Random<MatrixType> >;
Random(int rows, int cols) : m_rows(rows), m_cols(cols)
{
assert(rows > 0 && cols > 0);
}
private:
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
@@ -50,6 +45,15 @@ template<typename MatrixType> class Random : NoOperatorEquals,
{
return random<Scalar>();
}
public:
Random(int rows, int cols) : m_rows(rows), m_cols(cols)
{
assert(rows > 0
&& (_RowsAtCompileTime == Dynamic || _RowsAtCompileTime == rows)
&& cols > 0
&& (_ColsAtCompileTime == Dynamic || _ColsAtCompileTime == cols));
}
protected:
int m_rows, m_cols;

View File

@@ -60,9 +60,6 @@ template<typename MatrixType> class Row
assert(row >= 0 && row < matrix.rows());
}
Row(const Row& other)
: m_matrix(other.m_matrix), m_row(other.m_row) {}
template<typename OtherDerived>
Row& operator=(const MatrixBase<Scalar, OtherDerived>& other)
{

View File

@@ -37,9 +37,6 @@ template<typename FactorType, typename MatrixType> class ScalarMultiple : NoOper
ScalarMultiple(const MatRef& matrix, FactorType factor)
: m_matrix(matrix), m_factor(factor) {}
ScalarMultiple(const ScalarMultiple& other)
: m_matrix(other.m_matrix), m_factor(other.m_factor) {}
private:
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;

View File

@@ -41,8 +41,6 @@ template<typename Lhs, typename Rhs> class Sum : NoOperatorEquals,
assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
}
Sum(const Sum& other) : m_lhs(other.m_lhs), m_rhs(other.m_rhs) {}
private:
static const int _RowsAtCompileTime = Lhs::RowsAtCompileTime,
_ColsAtCompileTime = Rhs::ColsAtCompileTime;

View File

@@ -48,9 +48,6 @@ template<typename MatrixType> class Transpose
Transpose(const MatRef& matrix) : m_matrix(matrix) {}
Transpose(const Transpose& other)
: m_matrix(other.m_matrix) {}
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Transpose)
private:

View File

@@ -32,12 +32,7 @@ template<typename MatrixType> class Zero : NoOperatorEquals,
public:
typedef typename MatrixType::Scalar Scalar;
friend class MatrixBase<Scalar, Zero<MatrixType> >;
Zero(int rows, int cols) : m_rows(rows), m_cols(cols)
{
assert(rows > 0 && cols > 0);
}
private:
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
@@ -51,6 +46,15 @@ template<typename MatrixType> class Zero : NoOperatorEquals,
return static_cast<Scalar>(0);
}
public:
Zero(int rows, int cols) : m_rows(rows), m_cols(cols)
{
assert(rows > 0
&& (_RowsAtCompileTime == Dynamic || _RowsAtCompileTime == rows)
&& cols > 0
&& (_ColsAtCompileTime == Dynamic || _ColsAtCompileTime == cols));
}
protected:
int m_rows, m_cols;
};