Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
Public Types | Public Member Functions
ext::ptr_array< T, N > Class Template Reference

Implementation of array storing dynamicaly allocated instances of given type. The class mimicks the iterface of the standard library array, but effectively allows polymorphic objects to be stored inside. More...

#include <ptr_array.hpp>

Public Types

using value_type = T
 The type of values. More...
 
using size_type = std::size_t
 The type of sizes. More...
 
using diference_type = std::ptrdiff_t
 The type of size differences. More...
 
using reference = value_type &
 The type of reference to values. More...
 
using const_reference = const value_type &
 The type of reference to constant values. More...
 
using pointer = T *
 The type of pointer to values. More...
 
using const_pointer = const T *
 The type of pointer to constant value. More...
 
using iterator = dereferencing_iterator< typename std::array< T *, N >::iterator >
 The type of values iterator. More...
 
using const_iterator = dereferencing_iterator< typename std::array< T *, N >::const_iterator >
 The type of constant values iterator. More...
 
using reverse_iterator = dereferencing_iterator< typename std::array< T *, N >::reverse_iterator >
 The type of reverse values iterator. More...
 
using const_reverse_iterator = dereferencing_iterator< typename std::array< T *, N >::const_reverse_iterator >
 The type of constant reverse values iterator. More...
 

Public Member Functions

template<class ... Types>
 ptr_array (Types &&... args)
 Constructor of the array of pointers from parameter values. The resulting array is of size of the parameter pack. More...
 
template<class R = T>
 ptr_array ()
 The default constructor initializing the values of the array to the defaultly constructed value of T. More...
 
 ptr_array (const ptr_array &other)
 Copy constructor cloning all values in the source array. More...
 
 ptr_array (ptr_array &&other) noexcept
 Move constructor intended to transfer ownership of pointers from source to new instance. More...
 
 ~ptr_array () noexcept
 Destructor of the pointer array. More...
 
ptr_array< T, N > & operator= (const ptr_array< T, N > &other)
 Copy operator of assignment. The values of the source array are cloned to the new array. More...
 
ptr_array< T, N > & operator= (ptr_array< T, N > &&other) noexcept
 Move operator of assignment. The inner array of this and other instance are swapped. More...
 
template<class R >
void fill (const R &value)
 Fills the array with copies of value. More...
 
reference at (size_type index)
 Getter of value on index. More...
 
const_reference at (size_type index) const
 Getter of value on index. More...
 
reference operator[] (size_type index)
 Array subscript operator. More...
 
const_reference operator[] (size_type index) const
 Array subscript operator. More...
 
reference front ()
 Getter of the first value in the array. More...
 
const_reference front () const
 Getter of the first value in the array. More...
 
reference back ()
 Getter of the last value in the array. More...
 
const_reference back () const
 Getter of the last value in the array. More...
 
bool null (size_type index) const
 Test function whether pointer on index. More...
 
iterator begin () &noexcept
 Iterator to the begining of the values range in the array. More...
 
const_iterator begin () const &noexcept
 Iterator to the begining of the values range in the array. More...
 
auto begin () &&noexcept
 Move iterator to the begining of the values range in the array. More...
 
const_iterator cbegin () const noexcept
 Iterator to the begining of the values range in the array. More...
 
iterator end () &noexcept
 Iterator one past the last element of the values range in the array. More...
 
const_iterator end () const &noexcept
 Iterator one past the last element of the values range in the array. More...
 
auto end () &&noexcept
 Move iterator to the begining of the values range in the array. More...
 
const_iterator cend () const noexcept
 Iterator one past the last element of the values range in the array. More...
 
reverse_iterator rbegin () noexcept
 Reverse iterator to the begining of the reversed range of values in the array. More...
 
const_reverse_iterator rbegin () const noexcept
 Reverse iterator to the begining of the reversed range of values in the array. More...
 
const_reverse_iterator crbegin () const noexcept
 Reverse iterator to the begining of the reversed range of values in the array. More...
 
reverse_iterator rend () noexcept
 Reverse iterator one past the last element of the reversed range of values in the array. More...
 
const_reverse_iterator rend () const noexcept
 Reverse iterator one past the last element of the reversed range of values in the array. More...
 
const_reverse_iterator crend () const noexcept
 Reverse iterator one past the last element of the reversed range of values in the array. More...
 
auto range () &
 Make range of non-const begin to end iterators. More...
 
auto range () const &
 Make range of non-const begin to end iterators. More...
 
auto range () &&
 Make range of move begin to end iterators. More...
 
bool empty () const noexcept
 Array emptines test. More...
 
size_type size () const noexcept
 Getter of the array size. More...
 
size_type max_size () const noexcept
 Returns the maximal number of values possible to store inside the container. More...
 
template<class R >
iterator set (const_iterator pos, R &&value)
 Setter of value in the array on position specified by iterator specified by pos. The value is cloned from the value. More...
 
template<class R >
iterator set (const_reverse_iterator pos, R &&value)
 Setter of value in the array on position specified by iterator specified by pos. The value is cloned from the value. More...
 
template<class R , class ... Args>
iterator emplace_set (const_iterator pos, Args &&... args)
 Setter of internaly constructed value into the array on position specified by iterator specified by pos. The value is constructed from paramter pack. More...
 
template<class R , class ... Args>
iterator emplace_set (const_reverse_iterator pos, Args &&... args)
 Setter of internaly constructed value into the array on position specified by iterator specified by pos. The value is constructed from paramter pack. More...
 
void swap (ptr_array &other)
 
template<std::size_t I>
auto & get () &
 Getter of value on index given by template paramter. More...
 
template<std::size_t I>
const auto & get () const &
 Getter of value on index given by template paramter. More...
 
template<std::size_t I>
auto && get () &&
 Getter of value on index given by template paramter. More...
 
auto operator<=> (const ext::ptr_array< T, N > &second) const
 
bool operator== (const ext::ptr_array< T, N > &second) const
 Specialisation of equality operator for pointer array. More...
 

Detailed Description

template<class T, std::size_t N>
class ext::ptr_array< T, N >

Implementation of array storing dynamicaly allocated instances of given type. The class mimicks the iterface of the standard library array, but effectively allows polymorphic objects to be stored inside.

Template Parameters
Tthe type of stored values
Nthe size of the array

Member Typedef Documentation

◆ const_iterator

template<class T , std::size_t N>
using ext::ptr_array< T, N >::const_iterator = dereferencing_iterator < typename std::array < T *, N >::const_iterator >

The type of constant values iterator.

◆ const_pointer

template<class T , std::size_t N>
using ext::ptr_array< T, N >::const_pointer = const T *

The type of pointer to constant value.

◆ const_reference

template<class T , std::size_t N>
using ext::ptr_array< T, N >::const_reference = const value_type &

The type of reference to constant values.

◆ const_reverse_iterator

template<class T , std::size_t N>
using ext::ptr_array< T, N >::const_reverse_iterator = dereferencing_iterator < typename std::array < T *, N >::const_reverse_iterator >

The type of constant reverse values iterator.

◆ diference_type

template<class T , std::size_t N>
using ext::ptr_array< T, N >::diference_type = std::ptrdiff_t

The type of size differences.

◆ iterator

template<class T , std::size_t N>
using ext::ptr_array< T, N >::iterator = dereferencing_iterator < typename std::array < T *, N >::iterator >

The type of values iterator.

◆ pointer

template<class T , std::size_t N>
using ext::ptr_array< T, N >::pointer = T *

The type of pointer to values.

◆ reference

template<class T , std::size_t N>
using ext::ptr_array< T, N >::reference = value_type &

The type of reference to values.

◆ reverse_iterator

template<class T , std::size_t N>
using ext::ptr_array< T, N >::reverse_iterator = dereferencing_iterator < typename std::array < T *, N >::reverse_iterator >

The type of reverse values iterator.

◆ size_type

template<class T , std::size_t N>
using ext::ptr_array< T, N >::size_type = std::size_t

The type of sizes.

◆ value_type

template<class T , std::size_t N>
using ext::ptr_array< T, N >::value_type = T

The type of values.

Constructor & Destructor Documentation

◆ ptr_array() [1/4]

template<class T , std::size_t N>
template<class ... Types>
ext::ptr_array< T, N >::ptr_array ( Types &&...  args)
inline

Constructor of the array of pointers from parameter values. The resulting array is of size of the parameter pack.

Template Parameters
Types... the pack of source values type
Parameters
args... the actual source parameters

◆ ptr_array() [2/4]

template<class T , std::size_t N>
template<class R = T>
ext::ptr_array< T, N >::ptr_array ( )
inline

The default constructor initializing the values of the array to the defaultly constructed value of T.

Template Parameters
Rthe actual value to default construct on every array index

◆ ptr_array() [3/4]

template<class T , std::size_t N>
ext::ptr_array< T, N >::ptr_array ( const ptr_array< T, N > &  other)
inline

Copy constructor cloning all values in the source array.

Parameters
otherthe source array
Here is the call graph for this function:

◆ ptr_array() [4/4]

template<class T , std::size_t N>
ext::ptr_array< T, N >::ptr_array ( ptr_array< T, N > &&  other)
inlinenoexcept

Move constructor intended to transfer ownership of pointers from source to new instance.

Parameters
otherthe source array

◆ ~ptr_array()

template<class T , std::size_t N>
ext::ptr_array< T, N >::~ptr_array ( )
inlinenoexcept

Destructor of the pointer array.

Member Function Documentation

◆ at() [1/2]

template<class T , std::size_t N>
reference ext::ptr_array< T, N >::at ( size_type  index)
inline

Getter of value on index.

Parameters
indexthe position to access
Returns
reference to the value on given index
Here is the caller graph for this function:

◆ at() [2/2]

template<class T , std::size_t N>
const_reference ext::ptr_array< T, N >::at ( size_type  index) const
inline

Getter of value on index.

Parameters
indexthe position to access
Returns
reference to the value on given index

◆ back() [1/2]

template<class T , std::size_t N>
reference ext::ptr_array< T, N >::back ( )
inline

Getter of the last value in the array.

Returns
reference to the last value in the array

◆ back() [2/2]

template<class T , std::size_t N>
const_reference ext::ptr_array< T, N >::back ( ) const
inline

Getter of the last value in the array.

Returns
reference to the last value in the array

◆ begin() [1/3]

template<class T , std::size_t N>
auto ext::ptr_array< T, N >::begin ( ) &&
inlinenoexcept

Move iterator to the begining of the values range in the array.

Returns
iterator to the begining
Here is the call graph for this function:

◆ begin() [2/3]

template<class T , std::size_t N>
iterator ext::ptr_array< T, N >::begin ( ) &
inlinenoexcept

Iterator to the begining of the values range in the array.

Returns
iterator to the begining
Here is the call graph for this function:
Here is the caller graph for this function:

◆ begin() [3/3]

template<class T , std::size_t N>
const_iterator ext::ptr_array< T, N >::begin ( ) const &
inlinenoexcept

Iterator to the begining of the values range in the array.

Returns
iterator to the begining
Here is the call graph for this function:

◆ cbegin()

template<class T , std::size_t N>
const_iterator ext::ptr_array< T, N >::cbegin ( ) const
inlinenoexcept

Iterator to the begining of the values range in the array.

Returns
iterator to the begining
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cend()

template<class T , std::size_t N>
const_iterator ext::ptr_array< T, N >::cend ( ) const
inlinenoexcept

Iterator one past the last element of the values range in the array.

Returns
iterator to the end
Here is the call graph for this function:

◆ crbegin()

template<class T , std::size_t N>
const_reverse_iterator ext::ptr_array< T, N >::crbegin ( ) const
inlinenoexcept

Reverse iterator to the begining of the reversed range of values in the array.

Returns
reverse iterator to the begining
Here is the call graph for this function:
Here is the caller graph for this function:

◆ crend()

template<class T , std::size_t N>
const_reverse_iterator ext::ptr_array< T, N >::crend ( ) const
inlinenoexcept

Reverse iterator one past the last element of the reversed range of values in the array.

Returns
reverse iterator to the end
Here is the call graph for this function:

◆ emplace_set() [1/2]

template<class T , std::size_t N>
template<class R , class ... Args>
iterator ext::ptr_array< T, N >::emplace_set ( const_iterator  pos,
Args &&...  args 
)
inline

Setter of internaly constructed value into the array on position specified by iterator specified by pos. The value is constructed from paramter pack.

Template Parameters
Rthe actual type of constructed value
Args... types of value constructor parameters
Parameters
posthe iterator specifying position to set
args... value constructor parameters
Returns
iterator to the set value
Here is the call graph for this function:

◆ emplace_set() [2/2]

template<class T , std::size_t N>
template<class R , class ... Args>
iterator ext::ptr_array< T, N >::emplace_set ( const_reverse_iterator  pos,
Args &&...  args 
)
inline

Setter of internaly constructed value into the array on position specified by iterator specified by pos. The value is constructed from paramter pack.

Template Parameters
Rthe actual type of constructed value
Args... types of value constructor parameters
Parameters
posthe iterator specifying position to set
args... value constructor parameters
Returns
iterator to the set value
Here is the call graph for this function:

◆ empty()

template<class T , std::size_t N>
bool ext::ptr_array< T, N >::empty ( ) const
inlinenoexcept

Array emptines test.

Returns
true it array is empty, false othervise

◆ end() [1/3]

template<class T , std::size_t N>
auto ext::ptr_array< T, N >::end ( ) &&
inlinenoexcept

Move iterator to the begining of the values range in the array.

Returns
iterator to the begining
Here is the call graph for this function:

◆ end() [2/3]

template<class T , std::size_t N>
iterator ext::ptr_array< T, N >::end ( ) &
inlinenoexcept

Iterator one past the last element of the values range in the array.

Returns
iterator to the end
Here is the call graph for this function:
Here is the caller graph for this function:

◆ end() [3/3]

template<class T , std::size_t N>
const_iterator ext::ptr_array< T, N >::end ( ) const &
inlinenoexcept

Iterator one past the last element of the values range in the array.

Returns
iterator to the end
Here is the call graph for this function:

◆ fill()

template<class T , std::size_t N>
template<class R >
void ext::ptr_array< T, N >::fill ( const R &  value)
inline

Fills the array with copies of value.

Parameters
valuethe filling value
Here is the call graph for this function:

◆ front() [1/2]

template<class T , std::size_t N>
reference ext::ptr_array< T, N >::front ( )
inline

Getter of the first value in the array.

Returns
reference to the first value in the array

◆ front() [2/2]

template<class T , std::size_t N>
const_reference ext::ptr_array< T, N >::front ( ) const
inline

Getter of the first value in the array.

Returns
reference to the first value in the array

◆ get() [1/3]

template<class T , std::size_t N>
template<std::size_t I>
auto & ext::ptr_array< T, N >::get ( ) &
inline

Getter of value on index given by template paramter.

Template Parameters
Ithe index to access
Returns
the value on specified index.

◆ get() [2/3]

template<class T , std::size_t N>
template<std::size_t I>
auto && ext::ptr_array< T, N >::get ( ) &&
inline

Getter of value on index given by template paramter.

Template Parameters
Ithe index to access
Returns
the value on specified index.

◆ get() [3/3]

template<class T , std::size_t N>
template<std::size_t I>
const auto & ext::ptr_array< T, N >::get ( ) const &
inline

Getter of value on index given by template paramter.

Template Parameters
Ithe index to access
Returns
the value on specified index.

◆ max_size()

template<class T , std::size_t N>
size_type ext::ptr_array< T, N >::max_size ( ) const
inlinenoexcept

Returns the maximal number of values possible to store inside the container.

Returns
the maximal number of values

◆ null()

template<class T , std::size_t N>
bool ext::ptr_array< T, N >::null ( size_type  index) const
inline

Test function whether pointer on index.

Parameters
indexthe tested index
Returns
true if the pointer on index is null

◆ operator<=>()

template<class T , std::size_t N>
auto ext::ptr_array< T, N >::operator<=> ( const ext::ptr_array< T, N > &  second) const
inline
Here is the call graph for this function:

◆ operator=() [1/2]

template<class T , std::size_t N>
ptr_array< T, N > & ext::ptr_array< T, N >::operator= ( const ptr_array< T, N > &  other)
inline

Copy operator of assignment. The values of the source array are cloned to the new array.

Parameters
otherthe source instance
Here is the call graph for this function:

◆ operator=() [2/2]

template<class T , std::size_t N>
ptr_array< T, N > & ext::ptr_array< T, N >::operator= ( ptr_array< T, N > &&  other)
inlinenoexcept

Move operator of assignment. The inner array of this and other instance are swapped.

Parameters
otherthe source instance
Here is the call graph for this function:

◆ operator==()

template<class T , std::size_t N>
bool ext::ptr_array< T, N >::operator== ( const ext::ptr_array< T, N > &  second) const
inline

Specialisation of equality operator for pointer array.

Template Parameters
Tthe type of values inside the array
Nthe size of the array
Parameters
firstthe first compared value
secondthe second compared value
Returns
true if compared values are the same, false othervise
Here is the call graph for this function:

◆ operator[]() [1/2]

template<class T , std::size_t N>
reference ext::ptr_array< T, N >::operator[] ( size_type  index)
inline

Array subscript operator.

Parameters
theindex to retrieve
Returns
reference to the value on given index

◆ operator[]() [2/2]

template<class T , std::size_t N>
const_reference ext::ptr_array< T, N >::operator[] ( size_type  index) const
inline

Array subscript operator.

Parameters
theindex to retrieve
Returns
reference to the value on given index

◆ range() [1/3]

template<class T , std::size_t N>
auto ext::ptr_array< T, N >::range ( ) &
inline

Make range of non-const begin to end iterators.

Returns
full range over container values
Here is the call graph for this function:

◆ range() [2/3]

template<class T , std::size_t N>
auto ext::ptr_array< T, N >::range ( ) &&
inline

Make range of move begin to end iterators.

Returns
full range over container values

◆ range() [3/3]

template<class T , std::size_t N>
auto ext::ptr_array< T, N >::range ( ) const &
inline

Make range of non-const begin to end iterators.

Returns
full range over container values
Here is the call graph for this function:

◆ rbegin() [1/2]

template<class T , std::size_t N>
const_reverse_iterator ext::ptr_array< T, N >::rbegin ( ) const
inlinenoexcept

Reverse iterator to the begining of the reversed range of values in the array.

Returns
reverse iterator to the begining
Here is the call graph for this function:

◆ rbegin() [2/2]

template<class T , std::size_t N>
reverse_iterator ext::ptr_array< T, N >::rbegin ( )
inlinenoexcept

Reverse iterator to the begining of the reversed range of values in the array.

Returns
reverse iterator to the begining
Here is the call graph for this function:

◆ rend() [1/2]

template<class T , std::size_t N>
const_reverse_iterator ext::ptr_array< T, N >::rend ( ) const
inlinenoexcept

Reverse iterator one past the last element of the reversed range of values in the array.

Returns
reverse iterator to the end
Here is the call graph for this function:

◆ rend() [2/2]

template<class T , std::size_t N>
reverse_iterator ext::ptr_array< T, N >::rend ( )
inlinenoexcept

Reverse iterator one past the last element of the reversed range of values in the array.

Returns
reverse iterator to the end
Here is the call graph for this function:

◆ set() [1/2]

template<class T , std::size_t N>
template<class R >
iterator ext::ptr_array< T, N >::set ( const_iterator  pos,
R &&  value 
)
inline

Setter of value in the array on position specified by iterator specified by pos. The value is cloned from the value.

Template Parameters
Rthe actual type of constructed value
Parameters
posthe iterator specifying position to set
valuethe value to place at given position
Returns
iterator to the set value
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set() [2/2]

template<class T , std::size_t N>
template<class R >
iterator ext::ptr_array< T, N >::set ( const_reverse_iterator  pos,
R &&  value 
)
inline

Setter of value in the array on position specified by iterator specified by pos. The value is cloned from the value.

Template Parameters
Rthe actual type of constructed value
Parameters
posthe iterator specifying position to set
valuethe value to place at given position
Returns
iterator to the set value
Here is the call graph for this function:

◆ size()

template<class T , std::size_t N>
size_type ext::ptr_array< T, N >::size ( ) const
inlinenoexcept

Getter of the array size.

Returns
the size of the array
Here is the caller graph for this function:

◆ swap()

template<class T , std::size_t N>
void ext::ptr_array< T, N >::swap ( ptr_array< T, N > &  other)
inline

Swaps two instances of pointer array

Parameters
xthe other instance to swap with
Here is the call graph for this function:
Here is the caller graph for this function:

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