INLINE pointer address(reference r) { return &r; }
INLINE const_pointer address(const_reference r) { return &r; }
INLINE pointer allocate(size_type n, void_allocator_ptr = 0) {
- if (AlignOf<T>::value > sizeof(uintptr_t))
- return (pointer) GBE_ALIGNED_MALLOC(n*sizeof(T), AlignOf<T>::value);
+ if (ALIGNOF(T) > sizeof(uintptr_t))
+ return (pointer) GBE_ALIGNED_MALLOC(n*sizeof(T), ALIGNOF(T));
else
return (pointer) GBE_MALLOC(n * sizeof(T));
}
INLINE void deallocate(pointer p, size_type) {
- if (AlignOf<T>::value > sizeof(uintptr_t))
+ if (ALIGNOF(T) > sizeof(uintptr_t))
GBE_ALIGNED_FREE(p);
else
GBE_FREE(p);
}
void *allocate(void) {
#if GBE_DEBUG_SPECIAL_ALLOCATOR
- return GBE_ALIGNED_MALLOC(sizeof(T), AlignOf<T>::value);
+ return GBE_ALIGNED_MALLOC(sizeof(T), ALIGNOF(T));
#else
// Pick up an element from the free list
if (this->freeList != NULL) {
friend class GrowingPool;
GrowingPoolElem(size_t elemNum) {
const size_t sz = std::max(sizeof(T), sizeof(void*));
- this->data = (T*) GBE_ALIGNED_MALLOC(elemNum * sz, AlignOf<T>::value);
+ this->data = (T*) GBE_ALIGNED_MALLOC(elemNum * sz, ALIGNOF(T));
this->next = NULL;
this->maxElemNum = elemNum;
this->allocated = 0;
enum { value = offsetof(Helper, t) };
};
+//gcc 4.8+ support C++11 alignof keyword
+#if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 8)
+#define ALIGNOF(T) (alignof(T))
+#else
+#define ALIGNOF(T) (AlignOf<T>::value)
+#endif
+
////////////////////////////////////////////////////////////////////////////////
/// Visibility parameters (DLL export and so on)
////////////////////////////////////////////////////////////////////////////////