casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
casacore::arrays_internal::Storage< T, Alloc > Class Template Reference

This class emplements a static (but run-time) sized array. More...

#include <Storage.h>

Inheritance diagram for casacore::arrays_internal::Storage< T, Alloc >:

Classes

struct  conjunction
 
struct  conjunction< B1 >
 
struct  conjunction< B1, Bn...>
 
struct  disjunction
 Used by template code above These are already in C++17, but currently only using C++11... More...
 
struct  disjunction< B1 >
 
struct  disjunction< B1, Bn...>
 

Public Member Functions

 Storage (const Alloc &allocator)
 Construct an empty Storage. More...
 
 Storage (std::size_t n, const Alloc &allocator)
 Construct Storage with a given size. More...
 
 Storage (std::size_t n, const T &val, const Alloc &allocator)
 Construct Storage with a given size. More...
 
template<typename InputIterator >
 Storage (InputIterator startIter, InputIterator endIter, const Alloc &allocator)
 Construct Storage from a range. More...
 
 ~Storage () noexcept
 Destructs the elements and deallocates the data. More...
 
size_t size () const
 Size of the data, zero if empty. More...
 
const Alloc & get_allocator () const
 Returns the allocator associated with this Storage. More...
 
bool is_shared () const
 Whether this Storage owns its data. More...
 
 Storage (const Storage< T, Alloc > &)=delete
 
 Storage (Storage< T, Alloc > &&)=delete
 
Storageoperator= (const Storage &)=delete
 
Storageoperator= (Storage &&)=delete
 
T * data ()
 Return a pointer to the storage data. More...
 
const T * data () const
 

Static Public Member Functions

static std::unique_ptr
< Storage< T, Alloc > > 
MakeFromMove (T *startIter, T *endIter, const Alloc &allocator)
 Construct Storage from a range by moving. More...
 
static std::unique_ptr
< Storage< T, Alloc > > 
MakeFromSharedData (T *existingData, size_t n, const Alloc &allocator)
 Construct a Storage from existing data. More...
 
static std::unique_ptr
< Storage< T, Alloc > > 
MakeUninitialized (size_t n, const Alloc &allocator)
 Construct a Storage with uninitialized data. More...
 

Private Member Functions

 Storage (T *startIter, T *endIter, const Alloc &allocator, std::false_type, std::true_type)
 Moving range constructor implementation. More...
 
template<typename InputIterator >
 Storage (InputIterator startIter, InputIterator endIter, const Alloc &allocator, std::false_type)
 Copying range constructor implementation for non-integral types. More...
 
template<typename Integral >
 Storage (Integral n, Integral val, const Alloc &allocator, std::true_type)
 Copying range constructor implementation for integral types. More...
 
T * construct (size_t n)
 These methods allocate the storage and construct the elements. More...
 
T * construct (size_t n, const T &val)
 
template<typename InputIterator >
T * construct_range (InputIterator startIter, InputIterator endIter)
 
T * construct_move (T *startIter, T *endIter)
 

Private Attributes

T * _data
 
T * _end
 
bool _isShared
 

Detailed Description

template<typename T, typename Alloc>
class casacore::arrays_internal::Storage< T, Alloc >

This class emplements a static (but run-time) sized array.

It is used in the Array class, and is necessary because std::vector specializes for bool. It holds the same functionality as a normal array, and enables allocation through different allocators similar to std::vector.

Definition at line 16 of file Storage.h.

Constructor & Destructor Documentation

template<typename T , typename Alloc >
casacore::arrays_internal::Storage< T, Alloc >::Storage ( const Alloc &  allocator)
inline

Construct an empty Storage.

Definition at line 20 of file Storage.h.

Referenced by casacore::arrays_internal::Storage< T, Alloc >::MakeFromMove().

template<typename T , typename Alloc >
casacore::arrays_internal::Storage< T, Alloc >::Storage ( std::size_t  n,
const Alloc &  allocator 
)
inline

Construct Storage with a given size.

The elements will be default constructed

Definition at line 29 of file Storage.h.

template<typename T , typename Alloc >
casacore::arrays_internal::Storage< T, Alloc >::Storage ( std::size_t  n,
const T &  val,
const Alloc &  allocator 
)
inline

Construct Storage with a given size.

The elements will be copy constructed from the given value

Definition at line 38 of file Storage.h.

template<typename T , typename Alloc >
template<typename InputIterator >
casacore::arrays_internal::Storage< T, Alloc >::Storage ( InputIterator  startIter,
InputIterator  endIter,
const Alloc &  allocator 
)
inline

Construct Storage from a range.

The elements will be copy constructed from the given values. Note that this constructor can be chosen over of Storage(std::size_t, const T&, const Alloc) when T=size_t. Therefore, this constructor forwards to the appropriate constructor based on whether T is an integral.

Definition at line 52 of file Storage.h.

template<typename T , typename Alloc >
casacore::arrays_internal::Storage< T, Alloc >::~Storage ( )
inlinenoexcept
template<typename T , typename Alloc >
casacore::arrays_internal::Storage< T, Alloc >::Storage ( const Storage< T, Alloc > &  )
delete
template<typename T , typename Alloc >
casacore::arrays_internal::Storage< T, Alloc >::Storage ( Storage< T, Alloc > &&  )
delete
template<typename T , typename Alloc >
casacore::arrays_internal::Storage< T, Alloc >::Storage ( T *  startIter,
T *  endIter,
const Alloc &  allocator,
std::false_type  ,
std::true_type   
)
inlineprivate

Moving range constructor implementation.

Parameter integral is only a place-holder.

Definition at line 130 of file Storage.h.

template<typename T , typename Alloc >
template<typename InputIterator >
casacore::arrays_internal::Storage< T, Alloc >::Storage ( InputIterator  startIter,
InputIterator  endIter,
const Alloc &  allocator,
std::false_type   
)
inlineprivate

Copying range constructor implementation for non-integral types.

Definition at line 139 of file Storage.h.

template<typename T , typename Alloc >
template<typename Integral >
casacore::arrays_internal::Storage< T, Alloc >::Storage ( Integral  n,
Integral  val,
const Alloc &  allocator,
std::true_type   
)
inlineprivate

Copying range constructor implementation for integral types.

Definition at line 148 of file Storage.h.

Member Function Documentation

template<typename T , typename Alloc >
T* casacore::arrays_internal::Storage< T, Alloc >::construct ( size_t  n)
inlineprivate

These methods allocate the storage and construct the elements.

When any element constructor throws, the already constructed elements are destructed in reverse and the allocated storage is deallocated.

Definition at line 160 of file Storage.h.

References casacore::arrays_internal::Storage< T, Alloc >::data().

template<typename T , typename Alloc >
T* casacore::arrays_internal::Storage< T, Alloc >::construct ( size_t  n,
const T &  val 
)
inlineprivate

Definition at line 184 of file Storage.h.

References casacore::arrays_internal::Storage< T, Alloc >::data().

template<typename T , typename Alloc >
T* casacore::arrays_internal::Storage< T, Alloc >::construct_move ( T *  startIter,
T *  endIter 
)
inlineprivate

Definition at line 235 of file Storage.h.

References casacore::arrays_internal::Storage< T, Alloc >::data().

template<typename T , typename Alloc >
template<typename InputIterator >
T* casacore::arrays_internal::Storage< T, Alloc >::construct_range ( InputIterator  startIter,
InputIterator  endIter 
)
inlineprivate

Definition at line 209 of file Storage.h.

References casacore::arrays_internal::Storage< T, Alloc >::data().

template<typename T , typename Alloc >
T* casacore::arrays_internal::Storage< T, Alloc >::data ( )
inline
template<typename T , typename Alloc >
const T* casacore::arrays_internal::Storage< T, Alloc >::data ( ) const
inline

Definition at line 110 of file Storage.h.

References casacore::arrays_internal::Storage< T, Alloc >::_data.

template<typename T , typename Alloc >
const Alloc& casacore::arrays_internal::Storage< T, Alloc >::get_allocator ( ) const
inline

Returns the allocator associated with this Storage.

Definition at line 117 of file Storage.h.

template<typename T , typename Alloc >
bool casacore::arrays_internal::Storage< T, Alloc >::is_shared ( ) const
inline

Whether this Storage owns its data.

Returns true when this Storage was constructed with MakeFromSharedData().

Definition at line 121 of file Storage.h.

References casacore::arrays_internal::Storage< T, Alloc >::_isShared.

template<typename T , typename Alloc >
static std::unique_ptr<Storage<T, Alloc> > casacore::arrays_internal::Storage< T, Alloc >::MakeFromMove ( T *  startIter,
T *  endIter,
const Alloc &  allocator 
)
inlinestatic

Construct Storage from a range by moving.

The elements will be move constructed from the given values.

Definition at line 65 of file Storage.h.

References casacore::arrays_internal::Storage< T, Alloc >::Storage().

template<typename T , typename Alloc >
static std::unique_ptr<Storage<T, Alloc> > casacore::arrays_internal::Storage< T, Alloc >::MakeFromSharedData ( T *  existingData,
size_t  n,
const Alloc &  allocator 
)
inlinestatic

Construct a Storage from existing data.

The given pointer will not be owned by this class.

Definition at line 72 of file Storage.h.

template<typename T , typename Alloc >
static std::unique_ptr<Storage<T, Alloc> > casacore::arrays_internal::Storage< T, Alloc >::MakeUninitialized ( size_t  n,
const Alloc &  allocator 
)
inlinestatic

Construct a Storage with uninitialized data.

This will skip the constructor of the elements. This is only allowed for trivial types.

Definition at line 84 of file Storage.h.

References casacore::value().

template<typename T , typename Alloc >
Storage& casacore::arrays_internal::Storage< T, Alloc >::operator= ( const Storage< T, Alloc > &  )
delete
template<typename T , typename Alloc >
Storage& casacore::arrays_internal::Storage< T, Alloc >::operator= ( Storage< T, Alloc > &&  )
delete
template<typename T , typename Alloc >
size_t casacore::arrays_internal::Storage< T, Alloc >::size ( ) const
inline

Member Data Documentation

template<typename T , typename Alloc >
T* casacore::arrays_internal::Storage< T, Alloc >::_data
private
template<typename T , typename Alloc >
T* casacore::arrays_internal::Storage< T, Alloc >::_end
private

Definition at line 278 of file Storage.h.

Referenced by casacore::arrays_internal::Storage< T, Alloc >::size().

template<typename T , typename Alloc >
bool casacore::arrays_internal::Storage< T, Alloc >::_isShared
private

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