mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-04 11:10:40 +08:00
add missing delete operator overloads
This commit is contained in:
parent
5f35869461
commit
2beec14503
@ -630,6 +630,8 @@ template<typename T> class aligned_stack_memory_handler
|
|||||||
} \
|
} \
|
||||||
void operator delete(void * ptr) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \
|
void operator delete(void * ptr) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \
|
||||||
void operator delete[](void * ptr) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \
|
void operator delete[](void * ptr) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \
|
||||||
|
void operator delete(void * ptr, std::size_t /* sz */) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \
|
||||||
|
void operator delete[](void * ptr, std::size_t /* sz */) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \
|
||||||
/* in-place new and delete. since (at least afaik) there is no actual */ \
|
/* in-place new and delete. since (at least afaik) there is no actual */ \
|
||||||
/* memory allocated we can safely let the default implementation handle */ \
|
/* memory allocated we can safely let the default implementation handle */ \
|
||||||
/* this particular case. */ \
|
/* this particular case. */ \
|
||||||
|
@ -87,6 +87,32 @@ template<typename T> void check_dynaligned()
|
|||||||
delete obj;
|
delete obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T> void check_custom_new_delete()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
T* t = new T;
|
||||||
|
delete t;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::size_t N = internal::random<std::size_t>(1,10);
|
||||||
|
T* t = new T[N];
|
||||||
|
delete[] t;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef EIGEN_ALIGN
|
||||||
|
{
|
||||||
|
T* t = static_cast<T *>((T::operator new)(sizeof(T)));
|
||||||
|
(T::operator delete)(t, sizeof(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
T* t = static_cast<T *>((T::operator new)(sizeof(T)));
|
||||||
|
(T::operator delete)(t);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void test_dynalloc()
|
void test_dynalloc()
|
||||||
{
|
{
|
||||||
// low level dynamic memory allocation
|
// low level dynamic memory allocation
|
||||||
@ -104,6 +130,11 @@ void test_dynalloc()
|
|||||||
CALL_SUBTEST(check_dynaligned<Matrix4f>() );
|
CALL_SUBTEST(check_dynaligned<Matrix4f>() );
|
||||||
CALL_SUBTEST(check_dynaligned<Vector4d>() );
|
CALL_SUBTEST(check_dynaligned<Vector4d>() );
|
||||||
CALL_SUBTEST(check_dynaligned<Vector4i>() );
|
CALL_SUBTEST(check_dynaligned<Vector4i>() );
|
||||||
|
|
||||||
|
CALL_SUBTEST( check_custom_new_delete<Vector4f>() );
|
||||||
|
CALL_SUBTEST( check_custom_new_delete<Vector2f>() );
|
||||||
|
CALL_SUBTEST( check_custom_new_delete<Matrix4f>() );
|
||||||
|
CALL_SUBTEST( check_custom_new_delete<MatrixXi>() );
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user