mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-22 01:29:35 +08:00
SparseRef: Fixed alignment warning on ARM GCC
This commit is contained in:
parent
743c925286
commit
86eb41f1cb
@ -612,6 +612,16 @@ template<typename T, typename U> struct scalar_product_traits
|
||||
// typedef typename scalar_product_traits<typename remove_all<ArgType0>::type, typename remove_all<ArgType1>::type>::ReturnType type;
|
||||
// };
|
||||
|
||||
/** \internal Obtains a POD type suitable to use as storage for an object of a size
|
||||
* of at most Len bytes, aligned as specified by \c Align.
|
||||
*/
|
||||
template<unsigned Len, unsigned Align>
|
||||
struct aligned_storage {
|
||||
struct type {
|
||||
EIGEN_ALIGN_TO_BOUNDARY(Align) unsigned char data[Len];
|
||||
};
|
||||
};
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
namespace numext {
|
||||
|
@ -201,7 +201,7 @@ class Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType
|
||||
|
||||
~Ref() {
|
||||
if(m_hasCopy) {
|
||||
TPlainObjectType* obj = reinterpret_cast<TPlainObjectType*>(m_object_bytes);
|
||||
TPlainObjectType* obj = reinterpret_cast<TPlainObjectType*>(&m_storage);
|
||||
obj->~TPlainObjectType();
|
||||
}
|
||||
}
|
||||
@ -213,7 +213,7 @@ class Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType
|
||||
{
|
||||
if((Options & int(StandardCompressedFormat)) && (!expr.isCompressed()))
|
||||
{
|
||||
TPlainObjectType* obj = reinterpret_cast<TPlainObjectType*>(m_object_bytes);
|
||||
TPlainObjectType* obj = reinterpret_cast<TPlainObjectType*>(&m_storage);
|
||||
::new (obj) TPlainObjectType(expr);
|
||||
m_hasCopy = true;
|
||||
Base::construct(*obj);
|
||||
@ -227,14 +227,14 @@ class Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType
|
||||
template<typename Expression>
|
||||
void construct(const Expression& expr, internal::false_type)
|
||||
{
|
||||
TPlainObjectType* obj = reinterpret_cast<TPlainObjectType*>(m_object_bytes);
|
||||
TPlainObjectType* obj = reinterpret_cast<TPlainObjectType*>(&m_storage);
|
||||
::new (obj) TPlainObjectType(expr);
|
||||
m_hasCopy = true;
|
||||
Base::construct(*obj);
|
||||
}
|
||||
|
||||
protected:
|
||||
char m_object_bytes[sizeof(TPlainObjectType)];
|
||||
typename internal::aligned_storage<sizeof(TPlainObjectType), EIGEN_ALIGNOF(TPlainObjectType)>::type m_storage;
|
||||
bool m_hasCopy;
|
||||
};
|
||||
|
||||
@ -319,7 +319,7 @@ class Ref<const SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType
|
||||
|
||||
~Ref() {
|
||||
if(m_hasCopy) {
|
||||
TPlainObjectType* obj = reinterpret_cast<TPlainObjectType*>(m_object_bytes);
|
||||
TPlainObjectType* obj = reinterpret_cast<TPlainObjectType*>(&m_storage);
|
||||
obj->~TPlainObjectType();
|
||||
}
|
||||
}
|
||||
@ -335,14 +335,14 @@ class Ref<const SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType
|
||||
template<typename Expression>
|
||||
void construct(const Expression& expr, internal::false_type)
|
||||
{
|
||||
TPlainObjectType* obj = reinterpret_cast<TPlainObjectType*>(m_object_bytes);
|
||||
TPlainObjectType* obj = reinterpret_cast<TPlainObjectType*>(&m_storage);
|
||||
::new (obj) TPlainObjectType(expr);
|
||||
m_hasCopy = true;
|
||||
Base::construct(*obj);
|
||||
}
|
||||
|
||||
protected:
|
||||
char m_object_bytes[sizeof(TPlainObjectType)];
|
||||
typename internal::aligned_storage<sizeof(TPlainObjectType), EIGEN_ALIGNOF(TPlainObjectType)>::type m_storage;
|
||||
bool m_hasCopy;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user