29 #ifndef CASA_CONTAINERS_ALLOCATOR_H_
30 #define CASA_CONTAINERS_ALLOCATOR_H_
32 #include <casacore/casa/config.h>
40 #include <type_traits>
44 #ifndef CASA_DEFAULT_ALIGNMENT
45 # define CASA_DEFAULT_ALIGNMENT (32UL) // AVX/AVX2 alignment
79 template<
typename T,
size_t ALIGNMENT = CASA_DEFAULT_ALIGNMENT>
92 template<
typename TOther>
103 template<
typename TOther>
111 if (elements > this->max_size()) {
112 throw std::bad_alloc();
115 int result = posix_memalign(&memptr, ALIGNMENT,
sizeof(T) * elements);
117 throw std::bad_alloc();
119 return static_cast<pointer>(memptr);
127 template<
typename T,
size_t ALIGNMENT>
133 template<
typename T,
size_t ALIGNMENT>
150 template<
typename TOther>
161 template<
typename TOther>
169 if (elements > this->max_size()) {
170 throw std::bad_alloc();
172 return new T[elements];
178 template<
typename U,
typename... Args>
209 template<
typename T>
class Array;
210 template<
typename T>
class Block;
215 template<
typename T>
friend class Array;
216 template<
typename T>
friend class Block;
218 template<
typename T2>
220 typedef typename std::allocator<T2>::size_type
size_type;
221 typedef typename std::allocator<T2>::pointer
pointer;
236 template<
typename Allocator>
243 return allocator.allocate(elements, ptr);
252 for (i = 0; i < n; ++i) {
264 for (i = 0; i < n; ++i) {
265 allocator.construct(&ptr[i], initial_value);
275 for (i = 0; i < n; ++i) {
294 return typeid(Allocator);
302 template<
typename Allocator>
304 return get_allocator_raw<Allocator>();
307 template<
typename Allocator>
329 template<
typename Allocator>
330 Allocator Allocator_private::BulkAllocatorImpl<Allocator>::allocator;
345 template<
typename T,
typename Sub>
355 return Allocator_private::get_allocator<typename facade_type::type>();
379 template<
typename T,
size_t ALIGNMENT = CASA_DEFAULT_ALIGNMENT>
388 template<
typename T,
size_t ALIGNMENT>
virtual Allocator_private::BulkAllocator< T > * getAllocator() const =0
std::allocator< T2 >::pointer pointer
AlignedAllocator< T >::type type
std::allocator< T2 >::const_pointer const_pointer
void construct(U *ptr, U const &value)
Super::const_reference const_reference
static constexpr ArrayInitPolicy NO_INIT
Don't initialize elements in the array.
An allocator which allocates aligned memory.
static constexpr size_t alignment
Super::const_pointer const_pointer
static NewDelAllocator< T > value
an instance of this allocator.
std::allocator< T > std11_allocator
std::allocator< T2 >::size_type size_type
An aligned allocator with the default alignment.
each selection effectively specify the desired channel data in a specified spectral window If the user uses the FrequencySelectionChannel class then the selection simply selects a range of channels The other derived class is FrequencySelectionReferential which specifies a range of frequencies in a specified frame of reference(e.g., LSRK).Unlike the other first method
void deallocate(pointer ptr, size_type)
LatticeExprNode operator!=(const LatticeExprNode &left, const LatticeExprNode &right)
virtual void construct(pointer ptr, size_type n, const_pointer src)=0
virtual void destroy(pointer ptr, size_type n)=0
~new_del_allocator() noexcept
virtual casacore::String type() const
Implements RegionShape::type.
static AllocSpec< T > const value
Super::difference_type difference_type
Allocator::const_pointer const_pointer
Allocator::size_type size_type
new_del_allocator< TOther > other
new_del_allocator() noexcept
pointer allocate(size_type elements, const void *=0)
A global enum used by some Array/Block constructors.
static AlignedAllocator< T, ALIGNMENT > value
an instance of this allocator.
Super::size_type size_type
static DefaultAllocator< T > value
an instance of this allocator.
new_del_allocator< T > type
virtual void deallocate(pointer ptr, size_type size) override
casacore_allocator< TOther > other
virtual pointer allocate(size_type elements, const void *ptr=0) override
new_del_allocator(const new_del_allocator &other) noexcept
Super::value_type value_type
virtual std::type_info const & allocator_typeid() const =0
virtual ~BulkAllocatorImpl() override
casacore_allocator< T, ALIGNMENT > type
new_del_allocator(const new_del_allocator< TOther > &) noexcept
Super::const_pointer const_pointer
virtual pointer allocate(size_type elements, const void *ptr=0)=0
virtual std::type_info const & allocator_typeid() const override
Super::const_reference const_reference
Allocator::value_type value_type
virtual void destroy(pointer ptr, size_type n) override
~casacore_allocator() noexcept
void deallocate(pointer ptr, size_type)
void construct(U *ptr, U &&value)
virtual void deallocate(pointer ptr, size_type size)=0
BulkAllocator< T > * allocator
constexpr ArrayInitPolicy(bool v)
bool Bool
Define the standard types used by Casacore.
virtual void construct(pointer ptr, size_type n, const_pointer src) override
static BulkAllocatorImpl< Allocator > * get_allocator_raw()
static constexpr ArrayInitPolicy INIT
Initialize all elements in the array with the default value.
virtual void construct(pointer ptr, size_type n, value_type const &initial_value) override
template <class T, class U> class vector;
std::allocator< T2 >::value_type value_type
Bool operator!=(ArrayInitPolicy const &other)
pointer allocate(size_type elements, const void *=0)
virtual void construct(pointer ptr, size_type n) override
static Allocator allocator
void construct(U *, Args &&...)
void construct(U *ptr, U &value)
virtual Allocator_private::BulkAllocator< T > * getAllocator() const override
Bool operator==(ArrayInitPolicy const &other)
AllocSpec(BulkAllocator< T > *alloc)
Super::value_type value_type
casacore_allocator(const casacore_allocator &other) noexcept
Super::reference reference
virtual ~AbstractAllocator()
static BulkAllocator< typename Allocator::value_type > * get_allocator()
An allocator behaves like operator new[]/delete[].
Super::reference reference
casacore_allocator(const casacore_allocator< TOther > &) noexcept
Bool operator==(const MVTime &lh, const MVTime &rh)
is equal operator, uses operator Double which returns days
std11_allocator< T > Super
Super::size_type size_type
Allocator::pointer pointer
Super::difference_type difference_type
std11_allocator< T > Super
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
#define casacore
<X11/Intrinsic.h> #defines true, false, casacore::Bool, and String.