From 3a4616d6e3d7d60af5ba569b0d36e954d45a6fb9 Mon Sep 17 00:00:00 2001 From: Martinho Fernandes Date: Fri, 10 Jan 2014 11:02:11 +0100 Subject: [PATCH 1/2] Add C++11 allocator overloads to avoid implicit conversions. --- Eigen/src/Core/util/Memory.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index d177e8b5a..c1050e1ea 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -761,11 +761,27 @@ public: ::new( p ) T( value ); } +#if (__cplusplus >= 201103L) + template + void construct( U* u, Args&&... args) + { + ::new( u ) U( std::forward( args )... ); + } +#endif + void destroy( pointer p ) { p->~T(); } +#if (__cplusplus >= 201103L) + template + void destroy( U* u ) + { + u->~U(); + } +#endif + void deallocate( pointer p, size_type /*num*/ ) { internal::aligned_free( p ); From 4ccff2d028e9e39c66c4f003c7c077a0805d3023 Mon Sep 17 00:00:00 2001 From: Martinho Fernandes Date: Fri, 10 Jan 2014 11:20:40 +0100 Subject: [PATCH 2/2] Placement new must use void* to avoid user-specific overloads. --- Eigen/src/Core/util/Memory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index c1050e1ea..d1b08ed4c 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -765,7 +765,7 @@ public: template void construct( U* u, Args&&... args) { - ::new( u ) U( std::forward( args )... ); + ::new( static_cast(u) ) U( std::forward( args )... ); } #endif