Skip to content

Commit

Permalink
non_owning_storage move semantic, solved pessimizing-move warning in …
Browse files Browse the repository at this point in the history
…binary_matrix
  • Loading branch information
AlePalu committed Mar 8, 2024
1 parent e3f061d commit 4552388
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fdaPDE/linear_algebra/binary_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ template <int Rows, int Cols, typename XprType> class BinMtxBase {
for (int j = 0; j < mtx.cols(); ++j) {
if (!get().operator()(i, j)) masked_mtx(i, j) = 0;
}
return std::move(masked_mtx);
return masked_mtx;
}
template <typename ExprType>
SpMatrix<typename ExprType::Scalar> select(const Eigen::SparseMatrixBase<ExprType>& mtx) const {
Expand All @@ -482,7 +482,7 @@ template <int Rows, int Cols, typename XprType> class BinMtxBase {
for (typename SpMatrix<Scalar_>::InnerIterator it(masked_mtx, k); it; ++it) {
if (!get().operator()(it.row(), it.col())) { it.valueRef() = 0; }
}
return std::move(masked_mtx);
return masked_mtx;
}
// block-repeat operation
BinMtxBlockRepeatOp<Dynamic, Dynamic, XprType> blk_repeat(int rep_row, int rep_col) const {
Expand Down
5 changes: 5 additions & 0 deletions fdaPDE/utils/type_erasure.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ struct non_owning_storage {
ptr_ = other.ptr_;
return *this;
}
non_owning_storage(non_owning_storage&& other) : ptr_(std::exchange(other.ptr_, nullptr)) { }
non_owning_storage& operator=(non_owning_storage&& other) {
ptr_ = std::exchange(other.ptr_, nullptr);
return *this;
}
};

struct heap_storage {
Expand Down

0 comments on commit 4552388

Please sign in to comment.