Add construct_at, destroy_at wrappers. Use throughout.

This commit is contained in:
Tobias Schlüter
2022-03-08 20:43:22 +00:00
committed by Rasmus Munk Larsen
parent dfa5176780
commit cd2ba9d03e
18 changed files with 78 additions and 51 deletions

View File

@@ -79,16 +79,16 @@ public:
template<typename MatrixDerived>
void grab(const EigenBase<MatrixDerived> &mat)
{
m_matrix.~Ref<const MatrixType>();
::new (&m_matrix) Ref<const MatrixType>(mat.derived());
internal::destroy_at(&m_matrix);
internal::construct_at(&m_matrix, mat.derived());
}
void grab(const Ref<const MatrixType> &mat)
{
if(&(mat.derived()) != &m_matrix)
{
m_matrix.~Ref<const MatrixType>();
::new (&m_matrix) Ref<const MatrixType>(mat);
internal::destroy_at(&m_matrix);
internal::construct_at(&m_matrix, mat);
}
}

View File

@@ -85,7 +85,7 @@ struct evaluator<SolveWithGuess<Decomposition,RhsType, GuessType> >
evaluator(const SolveType& solve)
: m_result(solve.rows(), solve.cols())
{
::new (static_cast<Base*>(this)) Base(m_result);
internal::construct_at<Base>(this, m_result);
m_result = solve.guess();
solve.dec()._solve_with_guess_impl(solve.rhs(), m_result);
}