29 #ifndef VC_ALLOCATOR_H_
30 #define VC_ALLOCATOR_H_
38 #include "common/macros.h"
51 #define Vc_DECLARE_ALLOCATOR(Type) \
54 template <> class allocator<Type> : public ::Vc::Allocator<Type> \
57 template <typename U> struct rebind { \
58 typedef ::std::allocator<U> other; \
62 const allocator &select_on_container_copy_construction() const { return *this; } \
66 #define Vc_DECLARE_ALLOCATOR(Type) \
69 template <> class allocator<Type> : public ::Vc::Allocator<Type> \
72 template <typename U> struct rebind { \
73 typedef ::std::allocator<U> other; \
79 namespace Vc_VERSIONED_NAMESPACE
133 #ifdef Vc_HAVE_STD_MAX_ALIGN_T
134 NaturalAlignment =
alignof(std::max_align_t),
135 #elif defined(Vc_HAVE_MAX_ALIGN_T)
136 NaturalAlignment =
alignof(::max_align_t),
138 NaturalAlignment =
sizeof(
void *) >
alignof(
long double) ?
sizeof(
void *) :
139 (
alignof(
long double) >
alignof(
long long) ?
alignof(
long double) :
alignof(
long long)),
150 Alignment =
alignof(T) > SimdAlignment ?
alignof(T) : SimdAlignment,
167 ExtraBytes = Alignment > NaturalAlignment ? Alignment : 0,
168 AlignmentMask = Alignment - 1
171 typedef size_t size_type;
172 typedef ptrdiff_t difference_type;
174 typedef const T* const_pointer;
175 typedef T& reference;
176 typedef const T& const_reference;
177 typedef T value_type;
179 template<
typename U>
struct rebind {
typedef Allocator<U> other; };
185 pointer address(reference x)
const {
return &x; }
186 const_pointer address(const_reference x)
const {
return &x; }
188 pointer allocate(size_type n,
const void* = 0)
190 if (n > this->max_size()) {
191 throw std::bad_alloc();
194 char *p =
static_cast<char *
>(::operator
new(n *
sizeof(T) + ExtraBytes));
195 if (ExtraBytes > 0) {
198 const char *null = 0;
199 p -= ((p - null) & AlignmentMask);
200 reinterpret_cast<char **
>(p)[-1] = pp;
202 return reinterpret_cast<pointer
>(p);
205 void deallocate(pointer p, size_type)
207 if (ExtraBytes > 0) {
208 p =
reinterpret_cast<pointer *
>(p)[-1];
210 ::operator
delete(p);
213 size_type max_size()
const throw() {
return size_t(-1) /
sizeof(T); }
217 const Allocator &select_on_container_copy_construction()
const {
return *
this; }
221 void construct(pointer p) { ::new(p) T(); }
224 void construct(pointer p,
const T& val) { ::new(p) T(val); }
225 void destroy(pointer p) { p->~T(); }
227 template<
typename U,
typename... Args>
void construct(U* p, Args&&... args)
229 ::new(p) U(std::forward<Args>(args)...);
231 template<
typename U>
void destroy(U* p) { p->~U(); }
246 template<
typename U>
struct rebind { typedef ::std::allocator<U> other; };
249 const allocator &select_on_container_copy_construction()
const {
return *
this; }
252 template <
typename T>
256 template<
typename U>
struct rebind { typedef ::std::allocator<U> other; };
259 const allocator &select_on_container_copy_construction()
const {
return *
this; }
262 template <
typename T, std::
size_t N,
typename V, std::
size_t M>
263 class allocator<
Vc::SimdArray<T, N, V, M>> :
public ::Vc::Allocator<Vc::SimdArray<T, N, V, M>>
266 template<
typename U>
struct rebind { typedef ::std::allocator<U> other; };
269 const allocator &select_on_container_copy_construction()
const {
return *
this; }
272 template <
typename T, std::
size_t N,
typename V, std::
size_t M>
273 class allocator<
Vc::SimdMaskArray<T, N, V, M>> :
public ::Vc::Allocator<Vc::SimdMaskArray<T, N, V, M>>
276 template<
typename U>
struct rebind { typedef ::std::allocator<U> other; };
279 const allocator &select_on_container_copy_construction()
const {
return *
this; }
284 #endif // VC_ALLOCATOR_H_
The main vector class for expressing data parallelism.
An allocator that uses global new and supports over-aligned types, as per [C++11 20.6.9].
#define Vc_IMPL_AVX
This macro is defined if the current translation unit is compiled with AVX instruction support (exclu...
#define Vc_IMPL_SSE
This macro is defined if the current translation unit is compiled with any version of SSE (but not AV...
Vector Classes Namespace.
#define Vc_IMPL_MIC
This macro is defined if the current translation unit is compiled for the Knights Corner Xeon Phi ins...