mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
DenseStorage safely copy/swap.
Fixes #2229. For dynamic matrices with fixed-sized storage, only copy/swap elements that have been set. Otherwise, this leads to inefficient copying, and potential UB for non-initialized elements.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
85a76a16ea
commit
d213a0bcea
@@ -566,6 +566,17 @@ template<typename T> struct smart_memmove_helper<T,false> {
|
||||
}
|
||||
};
|
||||
|
||||
#if EIGEN_HAS_RVALUE_REFERENCES
|
||||
template<typename T> EIGEN_DEVICE_FUNC T* smart_move(T* start, T* end, T* target)
|
||||
{
|
||||
return std::move(start, end, target);
|
||||
}
|
||||
#else
|
||||
template<typename T> EIGEN_DEVICE_FUNC T* smart_move(T* start, T* end, T* target)
|
||||
{
|
||||
return std::copy(start, end, target);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
*** Implementation of runtime stack allocation (falling back to malloc) ***
|
||||
|
||||
Reference in New Issue
Block a user