Eigen::aligned_allocator< T > Class Template Reference

STL compatible allocator to use with types requiring a non-standard alignment. More...

#include <Memory.h>

Classes

struct  rebind
 

Public Types

typedef std::size_t size_type
 
typedef std::ptrdiff_t difference_type
 
typedef Tpointer
 
typedef const Tconst_pointer
 
typedef Treference
 
typedef const Tconst_reference
 
typedef T value_type
 

Public Member Functions

 aligned_allocator ()=default
 
 aligned_allocator (const aligned_allocator &)=default
 
template<class U >
 aligned_allocator (const aligned_allocator< U > &)
 
template<class U >
constexpr bool operator== (const aligned_allocator< U > &) const noexcept
 
template<class U >
constexpr bool operator!= (const aligned_allocator< U > &) const noexcept
 
pointer allocate (size_type num, const void *=0)
 
void deallocate (pointer p, size_type)
 

Detailed Description

template<class T>
class Eigen::aligned_allocator< T >

STL compatible allocator to use with types requiring a non-standard alignment.

The memory is aligned as for dynamically aligned matrix/array types such as MatrixXd. By default, it will thus provide at least 16 bytes alignment and more in following cases:

  • 32 bytes alignment if AVX is enabled.
  • 64 bytes alignment if AVX512 is enabled.

This can be controlled using the EIGEN_MAX_ALIGN_BYTES macro as documented there .

Example:

// Matrix4f requires 16 bytes alignment:
std::map< int, Matrix4f, std::less<int>,
aligned_allocator<std::pair<const int, Matrix4f> > > my_map_mat4;
// Vector3f does not require 16 bytes alignment, no need to use Eigen's allocator:
std::map< int, Vector3f > my_map_vec3;
See also
\blank TopicStlContainers.

Member Typedef Documentation

◆ const_pointer

template<class T >
typedef const T* Eigen::aligned_allocator< T >::const_pointer

◆ const_reference

template<class T >
typedef const T& Eigen::aligned_allocator< T >::const_reference

◆ difference_type

template<class T >
typedef std::ptrdiff_t Eigen::aligned_allocator< T >::difference_type

◆ pointer

template<class T >
typedef T* Eigen::aligned_allocator< T >::pointer

◆ reference

template<class T >
typedef T& Eigen::aligned_allocator< T >::reference

◆ size_type

template<class T >
typedef std::size_t Eigen::aligned_allocator< T >::size_type

◆ value_type

template<class T >
typedef T Eigen::aligned_allocator< T >::value_type

Constructor & Destructor Documentation

◆ aligned_allocator() [1/3]

template<class T >
Eigen::aligned_allocator< T >::aligned_allocator ( )
default

◆ aligned_allocator() [2/3]

template<class T >
Eigen::aligned_allocator< T >::aligned_allocator ( const aligned_allocator< T > &  )
default

◆ aligned_allocator() [3/3]

template<class T >
template<class U >
Eigen::aligned_allocator< T >::aligned_allocator ( const aligned_allocator< U > &  )
inline
936 {}

Member Function Documentation

◆ allocate()

template<class T >
pointer Eigen::aligned_allocator< T >::allocate ( size_type  num,
const void *  = 0 
)
inline
954  {
955  internal::check_size_for_overflow<T>(num);
956  return static_cast<pointer>(internal::aligned_malloc(num * sizeof(T)));
957  }
T * pointer
Definition: Memory.h:920
EIGEN_DEVICE_FUNC void * aligned_malloc(std::size_t size)
Definition: Memory.h:199

References Eigen::internal::aligned_malloc().

◆ deallocate()

template<class T >
void Eigen::aligned_allocator< T >::deallocate ( pointer  p,
size_type   
)
inline
float * p
Definition: Tutorial_Map_using.cpp:9
EIGEN_DEVICE_FUNC void aligned_free(void *ptr)
Definition: Memory.h:224

References Eigen::internal::aligned_free(), and p.

◆ operator!=()

template<class T >
template<class U >
constexpr bool Eigen::aligned_allocator< T >::operator!= ( const aligned_allocator< U > &  ) const
inlineconstexprnoexcept
943  {
944  return false;
945  }

◆ operator==()

template<class T >
template<class U >
constexpr bool Eigen::aligned_allocator< T >::operator== ( const aligned_allocator< U > &  ) const
inlineconstexprnoexcept
939  {
940  return true;
941  }

The documentation for this class was generated from the following file: