casacore
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
casacore::arrays_internal::Storage< T > Class Template Reference

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

#include <Storage.h>

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

Static Public Member Functions

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

Private Member Functions

 Storage (T *startIter, T *endIter, std::false_type, std::true_type)
 Moving range constructor implementation.
 
template<typename InputIterator >
 Storage (InputIterator startIter, InputIterator endIter, std::false_type)
 Copying range constructor implementation for non-integral types.
 
template<typename Integral >
 Storage (Integral n, Integral val, std::true_type)
 Copying range constructor implementation for integral types.
 
T * construct (size_t n)
 These methods allocate the storage and construct the elements.
 
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>
class casacore::arrays_internal::Storage< T >

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

◆ Storage() [1/9]

template<typename T >
casacore::arrays_internal::Storage< T >::Storage ( )
inline

Construct an empty Storage.

Definition at line 20 of file Storage.h.

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

◆ Storage() [2/9]

template<typename T >
casacore::arrays_internal::Storage< T >::Storage ( std::size_t  n)
inline

Construct Storage with a given size.

The elements will be default constructed

Definition at line 28 of file Storage.h.

◆ Storage() [3/9]

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

Construct Storage with a given size.

The elements will be copy constructed from the given value

Definition at line 36 of file Storage.h.

◆ Storage() [4/9]

template<typename T >
template<typename InputIterator >
casacore::arrays_internal::Storage< T >::Storage ( InputIterator  startIter,
InputIterator  endIter 
)
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 49 of file Storage.h.

◆ ~Storage()

template<typename T >
casacore::arrays_internal::Storage< T >::~Storage ( )
inlinenoexcept

◆ Storage() [5/9]

template<typename T >
casacore::arrays_internal::Storage< T >::Storage ( const Storage< T > &  )
delete

◆ Storage() [6/9]

template<typename T >
casacore::arrays_internal::Storage< T >::Storage ( Storage< T > &&  )
delete

◆ Storage() [7/9]

template<typename T >
casacore::arrays_internal::Storage< T >::Storage ( T *  startIter,
T *  endIter,
std::false_type  ,
std::true_type   
)
inlineprivate

Moving range constructor implementation.

Parameter integral is only a place-holder.

Definition at line 124 of file Storage.h.

◆ Storage() [8/9]

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

Copying range constructor implementation for non-integral types.

Definition at line 132 of file Storage.h.

◆ Storage() [9/9]

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

Copying range constructor implementation for integral types.

Definition at line 140 of file Storage.h.

Member Function Documentation

◆ construct() [1/2]

template<typename T >
T * casacore::arrays_internal::Storage< T >::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 151 of file Storage.h.

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

◆ construct() [2/2]

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

Definition at line 175 of file Storage.h.

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

◆ construct_move()

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

Definition at line 226 of file Storage.h.

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

◆ construct_range()

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

Definition at line 200 of file Storage.h.

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

◆ data() [1/2]

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

◆ data() [2/2]

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

Definition at line 107 of file Storage.h.

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

◆ is_shared()

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

Whether this Storage owns its data.

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

Definition at line 115 of file Storage.h.

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

◆ MakeFromMove()

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

Construct Storage from a range by moving.

The elements will be move constructed from the given values.

Definition at line 62 of file Storage.h.

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

◆ MakeFromSharedData()

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

Construct a Storage from existing data.

The given pointer will not be owned by this class.

Definition at line 69 of file Storage.h.

◆ MakeUninitialized()

template<typename T >
static std::unique_ptr< Storage< T > > casacore::arrays_internal::Storage< T >::MakeUninitialized ( size_t  n)
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 81 of file Storage.h.

◆ operator=() [1/2]

template<typename T >
Storage & casacore::arrays_internal::Storage< T >::operator= ( const Storage< T > &  )
delete

◆ operator=() [2/2]

template<typename T >
Storage & casacore::arrays_internal::Storage< T >::operator= ( Storage< T > &&  )
delete

◆ size()

template<typename T >
size_t casacore::arrays_internal::Storage< T >::size ( ) const
inline

Member Data Documentation

◆ _data

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

◆ _end

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

Definition at line 269 of file Storage.h.

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

◆ _isShared

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

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