- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
template <typename T, size_t rows, size_t cols>
class Matrix {
public:
Matrix() :
m_matrix(new T[rows * cols])
{
// Make identity matrix, if possible
if ( rows == cols ) {
for ( size_t i = 0; i < rows; i++ )
m_matrix[i * cols + i] = 1; // FIXME: this is hack
}
}
// ...
Matrix<T, rows, cols>& operator =(Matrix<T, rows, cols> &&other) {
if ( this != &other ) {
delete [] m_matrix;
m_matrix = other.m_matrix;
other.m_matrix = new T[cols * rows];
other = static_cast<const Matrix&>(Matrix());
}
return *this;
}
// ...
};
Elvenfighter 30.11.2012 23:47 # 0
Elvenfighter 30.11.2012 23:58 # 0
?
TarasB 30.11.2012 23:55 # 0
Elvenfighter 30.11.2012 23:57 # +1
TarasB 01.12.2012 00:40 # +2
Тогда нах вообще кучу дёргать...