Vc  1.4.1
SIMD Vector Classes for C++
Allocator< T > Class Template Reference

Detailed Description

template<typename T>
class Vc::Allocator< T >

An allocator that uses global new and supports over-aligned types, as per [C++11 20.6.9].

Meant as a simple replacement for the allocator defined in the C++ Standard. Allocation is done using the global new/delete operators. But if the alignment property of T is larger than the size of a pointer, the allocate function allocates slightly more memory to adjust the pointer for correct alignment.

If the T does not require over-alignment no additional memory will be allocated.

Template Parameters
TThe type of objects to allocate.

Example:

struct Data {
Vc::float_v x, y, z;
};
void fun()
{
std::vector<Data> dat0; // this will use std::allocator<Data>, which probably ignores the
// alignment requirements for Data. Thus any access to dat0 may
// crash your program.
std::vector<Data, Vc::Allocator<Data> > dat1; // now std::vector will get correctly aligned
// memory. Accesses to dat1 are safe.
...

Vc ships a macro to conveniently tell STL to use Vc::Allocator per default for a given type:

struct Data {
Vc::float_v x, y, z;
};
Vc_DECLARE_ALLOCATOR(Data)
void fun()
{
std::vector<Data> dat0; // good now
...

Definition at line 128 of file Allocator.

#include <Vc/Allocator>


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