Nail to Nail Fingerprint Capture Challenge
API for participant-specific one-to-many template generation and template matching.
Public Types | Public Member Functions | List of all members
BiometricEvaluation::Memory::AutoArray< T > Class Template Reference

A C-style array wrapped in the facade of a C++ STL container. More...

#include <be_memory_autoarray.h>

Public Types

using value_type = T
 Type of element.
 
using size_type = size_t
 Type of subscripts, counts, etc.
 
using iterator = AutoArrayIterator< false, T >
 Iterator of element.
 
using const_iterator = AutoArrayIterator< true, T >
 Const iterator of element.
 
using reference = T &
 Reference to element.
 
using const_reference = const T &
 Const reference element.
 

Public Member Functions

 operator T* ()
 Convert AutoArray to T array. More...
 
 operator const T * () const
 Convert AutoArray to const T array. More...
 
reference operator[] (ptrdiff_t index)
 Subscripting operator overload with unchecked access. More...
 
const_reference operator[] (ptrdiff_t index) const
 Const subscripting operator overload with unchecked access. More...
 
reference at (ptrdiff_t index)
 Subscript into the AutoArray with checked access. More...
 
const_reference at (ptrdiff_t index) const
 Subscript into the AutoArray with checked access. More...
 
iterator begin ()
 Obtain an iterator to the beginning of the AutoArray. More...
 
const_iterator begin () const
 Obtain an iterator to the beginning of the AutoArray. More...
 
const_iterator cbegin () const
 Obtain an iterator to the beginning of the AutoArray. More...
 
iterator end ()
 Obtain an iterator to the end of the AutoArray. More...
 
const_iterator end () const
 Obtain an iterator to the end of the AutoArray. More...
 
const_iterator cend () const
 Obtain an iterator to the end of the AutoArray. More...
 
size_type size () const
 Obtain the number of accessible elements. More...
 
void resize (size_type new_size, bool free=false)
 Change the number of accessible elements. More...
 
void copy (const T *buffer)
 Deep-copy the contents of a buffer into this AutoArray. More...
 
void copy (const T *buffer, size_type size)
 Deep-copy the contents of a buffer into this AutoArray. More...
 
std::vector< T > to_vector () const
 Obtain a copy of elements in this AutoArray as a vector. More...
 
 AutoArray (size_type size=0)
 Construct an AutoArray. More...
 
 AutoArray (const AutoArray &copy)
 Construct an AutoArray. More...
 
 AutoArray (AutoArray &&rvalue) noexcept
 Construct an AutoArray. More...
 
 AutoArray (std::initializer_list< T > ilist)
 Construct an AutoArray. More...
 
AutoArrayoperator= (const AutoArray &other)
 Copy assignment operator overload performing a deep copy. More...
 
AutoArrayoperator= (AutoArray &&other) noexcept(noexcept(std::swap(std::declval< value_type & >(), std::declval< value_type & >())) &&noexcept(std::swap(std::declval< size_type & >(), std::declval< size_type & >())))
 Move assignment operator. More...
 
 ~AutoArray ()
 Destructor.
 

Detailed Description

template<class T>
class BiometricEvaluation::Memory::AutoArray< T >

A C-style array wrapped in the facade of a C++ STL container.

Objects of this type should be treated in the traditional manner for containers, where (size_type) construction creates an array of the given size, while {...} construction creates an array with the given elements.

Constructor & Destructor Documentation

◆ AutoArray() [1/4]

template<class T >
BiometricEvaluation::Memory::AutoArray< T >::AutoArray ( size_type  size = 0)
explicit

Construct an AutoArray.

Parameters
[in]sizeThe number of elements this AutoArray should initially hold.
Exceptions
Error::MemoryErrorCould not allocate new memory.

◆ AutoArray() [2/4]

template<class T >
BiometricEvaluation::Memory::AutoArray< T >::AutoArray ( const AutoArray< T > &  copy)

Construct an AutoArray.

Parameters
[in]copyAn AutoArray whose contents will be deep copied into the new AutoArray.
Exceptions
Error::MemoryErrorCould not allocate new memory.

◆ AutoArray() [3/4]

template<class T >
BiometricEvaluation::Memory::AutoArray< T >::AutoArray ( AutoArray< T > &&  rvalue)
noexcept

Construct an AutoArray.

Parameters
[in]rvalueAn rvalue reference to an AutoArray whose contents will be moved and destroyed.

◆ AutoArray() [4/4]

template<class T >
BiometricEvaluation::Memory::AutoArray< T >::AutoArray ( std::initializer_list< T >  ilist)

Construct an AutoArray.

Parameters
[in]ilistAn initializer list of type T.

Member Function Documentation

◆ at() [1/2]

template<class T >
BiometricEvaluation::Memory::AutoArray< T >::reference BiometricEvaluation::Memory::AutoArray< T >::at ( ptrdiff_t  index)

Subscript into the AutoArray with checked access.

Parameters
[in]indexSubscript into underlying storage.
Returns
Reference to the element at the specified index.
Exceptions
out_of_rangeSpecified index is outside the bounds of this AutoArray.

◆ at() [2/2]

template<class T >
BiometricEvaluation::Memory::AutoArray< T >::const_reference BiometricEvaluation::Memory::AutoArray< T >::at ( ptrdiff_t  index) const

Subscript into the AutoArray with checked access.

Parameters
indexSubscript into underlying storage.
Returns
Const reference to the element at the specified index.
Exceptions
out_of_rangeSpecified index is outside the bounds of this AutoArray.

◆ begin() [1/2]

Obtain an iterator to the beginning of the AutoArray.

Returns
Iterator positioned at the first element of the AutoArray.

◆ begin() [2/2]

Obtain an iterator to the beginning of the AutoArray.

Returns
Const iterator positioned at the first element of the AutoArray.

◆ cbegin()

Obtain an iterator to the beginning of the AutoArray.

Returns
Const iterator positioned at the first element of the AutoArray.

◆ cend()

Obtain an iterator to the end of the AutoArray.

Returns
Iterator positioned at the one-past-last element of the AutoArray.

◆ copy() [1/2]

template<class T >
void BiometricEvaluation::Memory::AutoArray< T >::copy ( const T *  buffer)

Deep-copy the contents of a buffer into this AutoArray.

Parameters
[in]bufferAn allocated buffer whose contents will be deep-copied into this object. Only size() bytes will be copied.
Warning
If buffer is smaller in size than the current size of the AutoArray, you MUST call copy(const T*, size_type). This method must only be used when buffer is larger than or equal to the size of the AutoArray.

◆ copy() [2/2]

template<class T >
void BiometricEvaluation::Memory::AutoArray< T >::copy ( const T *  buffer,
size_type  size 
)

Deep-copy the contents of a buffer into this AutoArray.

Parameters
[in]bufferAn allocated buffer whose contents will be deep-copied into this object.
[in]sizeThe number of bytes from buffer that will be deep-copied.
Warning
size must be less than or equal to the size of buffer.

◆ end() [1/2]

Obtain an iterator to the end of the AutoArray.

Returns
Iterator positioned at the one-past-last element of the AutoArray.

◆ end() [2/2]

Obtain an iterator to the end of the AutoArray.

Returns
Iterator positioned at the one-past-last element of the AutoArray.

◆ operator const T *()

template<class T >
BiometricEvaluation::Memory::AutoArray< T >::operator const T *

Convert AutoArray to const T array.

Returns
Const pointer to the beginning of the underlying array storage.

◆ operator T*()

template<class T >
BiometricEvaluation::Memory::AutoArray< T >::operator T*

Convert AutoArray to T array.

Returns
Pointer to the beginning of the underlying array storage.

◆ operator=() [1/2]

template<class T >
BiometricEvaluation::Memory::AutoArray< T > & BiometricEvaluation::Memory::AutoArray< T >::operator= ( AutoArray< T > &&  other)
noexcept

Move assignment operator.

Parameters
[in]otherrvalue reference to another AutoArray, whose contents will be moved and cleared from itself.
Returns
Reference to the lvalue AutoArray.

◆ operator=() [2/2]

template<class T >
BiometricEvaluation::Memory::AutoArray< T > & BiometricEvaluation::Memory::AutoArray< T >::operator= ( const AutoArray< T > &  other)

Copy assignment operator overload performing a deep copy.

Parameters
[in]otherAutoArray to be copied.
Returns
Reference to a new AutoArray object, the lvalue AutoArray.
Exceptions
Error::MemoryErrorCould not allocate new memory.

◆ operator[]() [1/2]

template<class T >
BiometricEvaluation::Memory::AutoArray< T >::reference BiometricEvaluation::Memory::AutoArray< T >::operator[] ( ptrdiff_t  index)

Subscripting operator overload with unchecked access.

Parameters
[in]indexSubscript into underlying storage.
Returns
Reference to the element at the specified index.

◆ operator[]() [2/2]

template<class T >
BiometricEvaluation::Memory::AutoArray< T >::const_reference BiometricEvaluation::Memory::AutoArray< T >::operator[] ( ptrdiff_t  index) const

Const subscripting operator overload with unchecked access.

Parameters
[in]indexSubscript into underlying storage.
Returns
Const reference to the element at the specified index.

◆ resize()

template<class T >
void BiometricEvaluation::Memory::AutoArray< T >::resize ( size_type  new_size,
bool  free = false 
)

Change the number of accessible elements.

Parameters
[in]new_sizeThe number of elements the AutoArray should have allocated.
[in]freeWhether or not excess memory should be freed if the new size is smaller than the current size.
Exceptions
Error::MemoryErrorProblem allocating memory.

◆ size()

Obtain the number of accessible elements.

Returns
Number of accessible elements.
Note
If resize() has been called, the value returned from size() may be smaller than the actual allocated size of the underlying storage.

◆ to_vector()

template<class T >
std::vector< T > BiometricEvaluation::Memory::AutoArray< T >::to_vector

Obtain a copy of elements in this AutoArray as a vector.

Warning
A key difference between vectors and AutoArrays is that all elements of a vector must be initialized. Calling this method on an AutoArray where not all elements have been initialized will likely cause undefined behavior.
Returns
A vector containing the contents of this AutoArray.