Skip to content
Snippets Groups Projects
Commit 87d9b800 authored by Ansgar Burchardt's avatar Ansgar Burchardt
Browse files

FieldMatrix should be trivially copyable and standard layout type

Closes: #169
parent 14fc1f32
No related branches found
No related tags found
1 merge request!688make `FieldMatrix` and `FieldVector` trivially copyable types
......@@ -87,7 +87,7 @@ namespace Dune
//===== constructors
/** \brief Default constructor
*/
FieldMatrix () {}
FieldMatrix() = default;
/** \brief Constructor initializing the matrix from a list of vector
*/
......@@ -107,16 +107,21 @@ namespace Dune
using Base::operator=;
// Specialisation: FieldMatrix assignment (compile-time bounds checking)
template <typename T, int rows, int cols>
FieldMatrix& operator=(FieldMatrix<T,rows,cols> const &rhs)
//! copy assignment operator
FieldMatrix& operator=(const FieldMatrix&) = default;
//! copy assignment from FieldMatrix over a different field
template<typename T>
FieldMatrix& operator=(const FieldMatrix<T, ROWS, COLS>& x)
{
static_assert(rows == ROWS, "Size mismatch in matrix assignment (rows)");
static_assert(cols == COLS, "Size mismatch in matrix assignment (columns)");
_data = rhs._data;
_data = x._data;
return *this;
}
//! no copy assignment from FieldMatrix of different size
template <typename T, int rows, int cols>
FieldMatrix& operator=(FieldMatrix<T,rows,cols> const&) = delete;
//! Multiplies M from the left to this matrix, this matrix is not modified
template<int l>
FieldMatrix<K,l,cols> leftmultiplyany (const FieldMatrix<K,l,rows>& M) const
......@@ -226,7 +231,7 @@ namespace Dune
//===== constructors
/** \brief Default constructor
*/
FieldMatrix () {}
FieldMatrix() = default;
/** \brief Constructor initializing the matrix from a list of vector
*/
......
......@@ -733,6 +733,15 @@ void test_interface()
typedef CheckMatrixInterface::UseFieldVector< K2, rows, cols > Traits;
typedef Dune::FieldMatrix< K, rows, cols > FMatrix;
static_assert(
!std::is_trivially_copyable<K>::value || std::is_trivially_copyable<FMatrix>::value,
"FieldMatrix<T, ...> must be trivally copyable type when T is trivial type"
);
static_assert(
std::is_standard_layout<FMatrix>::value,
"FieldMatrix<...> must be a standard layout type"
);
FMatrix m( 1 );
checkMatrixInterface< FMatrix >( m );
checkMatrixInterface< FMatrix, Traits >( m );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment