aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/util/Memory.h
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2014-03-26 15:23:59 -0700
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2014-03-26 15:23:59 -0700
commitcc73164aa84c711c5581d8e163e1bd496c768b8a (patch)
tree4889d847f64c027942c4c1627cefce120c1bdb63 /Eigen/src/Core/util/Memory.h
parenta078f442a382be64cc22f315ad300c353891a814 (diff)
parentbc401eb6fa9c4c14c7fb32acfe70b304c1850283 (diff)
Merged latest updates from the parent branch
Diffstat (limited to 'Eigen/src/Core/util/Memory.h')
-rw-r--r--Eigen/src/Core/util/Memory.h112
1 files changed, 28 insertions, 84 deletions
diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h
index 76447c5b6..a4d7e454d 100644
--- a/Eigen/src/Core/util/Memory.h
+++ b/Eigen/src/Core/util/Memory.h
@@ -700,98 +700,42 @@ template<typename T> class aligned_stack_memory_handler
* \sa \ref TopicStlContainers.
*/
template<class T>
-class aligned_allocator
+class aligned_allocator : public std::allocator<T>
{
public:
- typedef size_t size_type;
- typedef std::ptrdiff_t difference_type;
- typedef T* pointer;
- typedef const T* const_pointer;
- typedef T& reference;
- typedef const T& const_reference;
- typedef T value_type;
-
- template<class U>
- struct rebind
- {
- typedef aligned_allocator<U> other;
- };
-
- pointer address( reference value ) const
- {
- return &value;
- }
-
- const_pointer address( const_reference value ) const
- {
- return &value;
- }
-
- aligned_allocator()
- {
- }
-
- aligned_allocator( const aligned_allocator& )
- {
- }
-
- template<class U>
- aligned_allocator( const aligned_allocator<U>& )
- {
- }
-
- ~aligned_allocator()
- {
- }
-
- size_type max_size() const
- {
- return (std::numeric_limits<size_type>::max)();
- }
-
- pointer allocate( size_type num, const void* hint = 0 )
- {
- EIGEN_UNUSED_VARIABLE(hint);
- internal::check_size_for_overflow<T>(num);
- return static_cast<pointer>( internal::aligned_malloc( num * sizeof(T) ) );
- }
-
- void construct( pointer p, const T& value )
- {
- ::new( p ) T( value );
- }
+ typedef size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef T value_type;
+
+ template<class U>
+ struct rebind
+ {
+ typedef aligned_allocator<U> other;
+ };
-#if (__cplusplus >= 201103L)
- template <typename U, typename... Args>
- void construct( U* u, Args&&... args)
- {
- ::new( static_cast<void*>(u) ) U( std::forward<Args>( args )... );
- }
-#endif
+ aligned_allocator() : std::allocator<T>() {}
- void destroy( pointer p )
- {
- p->~T();
- }
+ aligned_allocator(const aligned_allocator& other) : std::allocator<T>(other) {}
-#if (__cplusplus >= 201103L)
- template <typename U>
- void destroy( U* u )
- {
- u->~U();
- }
-#endif
+ template<class U>
+ aligned_allocator(const aligned_allocator<U>& other) : std::allocator<T>(other) {}
- void deallocate( pointer p, size_type /*num*/ )
- {
- internal::aligned_free( p );
- }
+ ~aligned_allocator() {}
- bool operator!=(const aligned_allocator<T>& ) const
- { return false; }
+ pointer allocate(size_type num, const void* /*hint*/ = 0)
+ {
+ internal::check_size_for_overflow<T>(num);
+ return static_cast<pointer>( internal::aligned_malloc(num * sizeof(T)) );
+ }
- bool operator==(const aligned_allocator<T>& ) const
- { return true; }
+ void deallocate(pointer p, size_type /*num*/)
+ {
+ internal::aligned_free(p);
+ }
};
//---------- Cache sizes ----------