template class mrpt::aligned_allocator_cpp11

Aligned allocator that is compatible with C++11.

Default alignment can be 16 (default), 32 (if AVX is defined) or 64 (if AVX2 is defined). See: https://bitbucket.org/eigen/eigen/commits/f5b7700

This was used (before May-2019) to provide custom STL aligned containers, but the new(n,m) addition to C++17 rendered this needless (at last!) See: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1409

Anyway, this allocator class is left here just in case it is needed for something else.

#include <mrpt/core/aligned_allocator.h>

template <class T, size_t AligmentBytes = MRPT_MAX_ALIGN_BYTES>
class aligned_allocator_cpp11: public std::allocator< T >
{
public:
    // typedefs

    typedef std::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;

    // structs

    template <class U>
    struct rebind;

    //
fields

    T elements;

    // construction

    aligned_allocator_cpp11();
    aligned_allocator_cpp11(const aligned_allocator_cpp11& other);

    template <class U>
    aligned_allocator_cpp11(const aligned_allocator_cpp11<U>& other);

    //
methods

    pointer allocate(
        size_type num,
        const void* = nullptr
        );

    void deallocate(
        pointer p,
        size_type
        );
};

Fields

T elements

STL member.