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 f8132c8
Show file tree
Hide file tree
Showing 2 changed files with 5 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
3 changes: 3 additions & 0 deletions fdaPDE/utils/type_erasure.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ struct non_owning_storage {
ptr_ = other.ptr_;
return *this;
}
// move semantic to not transfer ownership, act as trivial copy semantic
non_owning_storage(non_owning_storage&& other) = default;
non_owning_storage& operator=(non_owning_storage&& other) = default;
};

struct heap_storage {
Expand Down

0 comments on commit f8132c8

Please sign in to comment.