Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Class template aligned_allocator_adaptor

boost::alignment::aligned_allocator_adaptor

Synopsis

// In header: <boost/align/aligned_allocator_adaptor.hpp>

template<typename Allocator, std::size_t Alignment> 
class aligned_allocator_adaptor : public Allocator {
public:
  // types
  typedef Traits::value_type value_type;        
  typedef Traits::size_type  size_type;         
  typedef value_type *       pointer;           
  typedef const value_type * const_pointer;     
  typedef void *             void_pointer;      
  typedef const void *       const_void_pointer;
  typedef std::ptrdiff_t     difference_type;   

  // member classes/structs/unions
  template<typename U> 
  struct rebind {
    // types
    typedef aligned_allocator_adaptor< typename Traits::template rebind_alloc< U >, Alignment > other;
  };

  // construct/copy/destruct
  aligned_allocator_adaptor() = default;
  template<typename A> explicit aligned_allocator_adaptor(A &&) noexcept;
  template<typename U> 
    aligned_allocator_adaptor(const aligned_allocator_adaptor< U, Alignment > &) noexcept;

  // public member functions
  Allocator & base() noexcept;
  const Allocator & base() const noexcept;
  pointer allocate(size_type);
  pointer allocate(size_type, const_void_pointer);
  void deallocate(pointer, size_type);
};

Description

Class template aligned_allocator_adaptor.

[Note] Note

This adaptor can be used with a C++11 allocator whose pointer type is a smart pointer but the adaptor will expose only raw pointers.

Template Parameters

  1. typename Allocator
  2. std::size_t Alignment

    Is the minimum alignment to specify for allocations, if it is larger than the alignment of the value type. The value of Alignment shall be a fundamental alignment value or an extended alignment value, and shall be a power of two.

aligned_allocator_adaptor public construct/copy/destruct

  1. aligned_allocator_adaptor() = default;

    Value-initializes the Allocator base class.

  2. template<typename A> explicit aligned_allocator_adaptor(A && alloc) noexcept;

    Initializes the Allocator base class with std::forward<A>(alloc).

    Require: Allocator shall be constructible from A.

  3. template<typename U> 
      aligned_allocator_adaptor(const aligned_allocator_adaptor< U, Alignment > & other) noexcept;

    Initializes the Allocator base class with the base from other.

aligned_allocator_adaptor public member functions

  1. Allocator & base() noexcept;

    Returns:

    static_cast<Allocator&>(*this).

  2. const Allocator & base() const noexcept;

    Returns:

    static_cast<const Allocator&>(*this).

  3. pointer allocate(size_type size);

    Throw: Throws an exception thrown from A2::allocate if the storage cannot be obtained.

    Note: The storage is obtained by calling A2::allocate on an object a2, where a2 of type A2 is a rebound copy of base() where its value_type is unspecified.

    Parameters:

    size

    The size of the value type object to allocate.

    Returns:

    A pointer to the initial element of an array of storage of size n * sizeof(value_type), aligned on the maximum of the minimum alignment specified and the alignment of objects of type value_type.

  4. pointer allocate(size_type size, const_void_pointer hint);

    Throw: Throws an exception thrown from A2::allocate if the storage cannot be obtained.

    Note: The storage is obtained by calling A2::allocate on an object a2, where a2 of type A2 is a rebound copy of base() where its value_type is unspecified.

    Parameters:

    hint

    is a value obtained by calling allocate() on any equivalent aligned allocator adaptor object, or else nullptr.

    size

    The size of the value type object to allocate.

    Returns:

    A pointer to the initial element of an array of storage of size n * sizeof(value_type), aligned on the maximum of the minimum alignment specified and the alignment of objects of type value_type.

  5. void deallocate(pointer ptr, size_type size);

    Deallocates the storage referenced by ptr.

    Note: Uses A2::deallocate on an object a2, where a2 of type A2 is a rebound copy of base() where its value_type is unspecified.

    Parameters:

    ptr

    Shall be a pointer value obtained from allocate().

    size

    Shall equal the value passed as the first argument to the invocation of allocate which returned ptr.


PrevUpHomeNext