28 #ifndef VC_ALLOCATOR_H_ 29 #define VC_ALLOCATOR_H_ 37 #include "common/macros.h" 50 #define Vc_DECLARE_ALLOCATOR(Type) \ 53 template <> class allocator<Type> : public ::Vc::Allocator<Type> \ 56 template <typename U> struct rebind { \ 57 typedef ::std::allocator<U> other; \ 61 const allocator &select_on_container_copy_construction() const { return *this; } \ 65 #define Vc_DECLARE_ALLOCATOR(Type) \ 68 template <> class allocator<Type> : public ::Vc::Allocator<Type> \ 71 template <typename U> struct rebind { \ 72 typedef ::std::allocator<U> other; \ 78 namespace Vc_VERSIONED_NAMESPACE
132 #ifdef Vc_HAVE_STD_MAX_ALIGN_T 133 NaturalAlignment =
alignof(std::max_align_t),
134 #elif defined(Vc_HAVE_MAX_ALIGN_T)
135 NaturalAlignment =
alignof(::max_align_t),
137 NaturalAlignment =
sizeof(
void *) >
alignof(
long double) ?
sizeof(
void *) :
138 (
alignof(
long double) >
alignof(
long long) ?
alignof(
long double) :
alignof(
long long)),
149 Alignment =
alignof(T) > SimdAlignment ?
alignof(T) : SimdAlignment,
166 ExtraBytes = Alignment > NaturalAlignment ? Alignment : 0,
167 AlignmentMask = Alignment - 1
170 typedef size_t size_type;
171 typedef ptrdiff_t difference_type;
173 typedef const T* const_pointer;
174 typedef T& reference;
175 typedef const T& const_reference;
176 typedef T value_type;
178 template<
typename U>
struct rebind {
typedef Allocator<U> other; };
184 pointer address(reference x)
const {
return &x; }
185 const_pointer address(const_reference x)
const {
return &x; }
187 pointer allocate(size_type n,
const void* = 0)
189 if (n > this->max_size()) {
190 throw std::bad_alloc();
193 char *p =
static_cast<char *
>(::operator
new(n *
sizeof(T) + ExtraBytes));
194 if (ExtraBytes > 0) {
197 const char *null = 0;
198 p -= ((p - null) & AlignmentMask);
199 reinterpret_cast<char **
>(p)[-1] = pp;
201 return reinterpret_cast<pointer
>(p);
204 void deallocate(pointer p, size_type)
206 if (ExtraBytes > 0) {
207 p =
reinterpret_cast<pointer *
>(p)[-1];
209 ::operator
delete(p);
212 size_type max_size()
const throw() {
return size_t(-1) /
sizeof(T); }
216 const Allocator &select_on_container_copy_construction()
const {
return *
this; }
220 void construct(pointer p) { ::new(p) T(); }
223 void construct(pointer p,
const T& val) { ::new(p) T(val); }
224 void destroy(pointer p) { p->~T(); }
226 template<
typename U,
typename... Args>
void construct(U* p, Args&&... args)
228 ::new(p) U(std::forward<Args>(args)...);
230 template<
typename U>
void destroy(U* p) { p->~U(); }
245 template<
typename U>
struct rebind { typedef ::std::allocator<U> other; };
248 const allocator &select_on_container_copy_construction()
const {
return *
this; }
251 template <
typename T>
255 template<
typename U>
struct rebind { typedef ::std::allocator<U> other; };
258 const allocator &select_on_container_copy_construction()
const {
return *
this; }
261 template <
typename T, std::
size_t N,
typename V, std::
size_t M>
265 template<
typename U>
struct rebind { typedef ::std::allocator<U> other; };
268 const allocator &select_on_container_copy_construction()
const {
return *
this; }
271 template <
typename T, std::
size_t N,
typename V, std::
size_t M>
275 template<
typename U>
struct rebind { typedef ::std::allocator<U> other; };
278 const allocator &select_on_container_copy_construction()
const {
return *
this; }
283 #endif // VC_ALLOCATOR_H_ The main vector class for expressing data parallelism.
result_vector_type< L, R >::mask_type operator!=(L &&lhs, R &&rhs)
Applies != component-wise and concurrently.
Data-parallel arithmetic type with user-defined number of elements.
Data-parallel mask type with user-defined number of boolean elements.
An allocator that uses global new and supports over-aligned types, as per [C++11 20.6.9].
result_vector_type< L, R >::mask_type operator==(L &&lhs, R &&rhs)
Applies == component-wise and concurrently.
#define Vc_IMPL_AVX
This macro is defined if the current translation unit is compiled with AVX instruction support (exclu...
The main SIMD mask class.
#define Vc_IMPL_SSE
This macro is defined if the current translation unit is compiled with any version of SSE (but not AV...
#define Vc_IMPL_MIC
This macro is defined if the current translation unit is compiled for the Knights Corner Xeon Phi ins...