|
Array
Boost.Array Library
|
A container that encapsulates fixed size arrays. More...
#include <array.hpp>
Public Types | |
Types | |
| typedef T | value_type |
| The array value type. More... | |
| typedef T * | iterator |
| Iterator to C-style array, i.e. a pointer. More... | |
| typedef const T * | const_iterator |
| Constant iterator to array, i.e. a pointer. More... | |
| typedef T & | reference |
| Reference to value type. More... | |
| typedef const T & | const_reference |
| Constant reference to value type. More... | |
| typedef std::size_t | size_type |
| Type used to represent array size. More... | |
| typedef std::ptrdiff_t | difference_type |
| Type used to represent distance between iterators. More... | |
| typedef std::reverse_iterator< iterator > | reverse_iterator |
| Reverse array iterator - std::reverse_iterator<iterator> More... | |
| typedef std::reverse_iterator< const_iterator > | const_reverse_iterator |
| Constant reverse array iterator - std::reverse_iterator<const_iterator> More... | |
Public Member Functions | |
Iterators | |
| iterator | begin () |
| Returns an iterator to the beginning. More... | |
| const_iterator | begin () const |
| Returns a constant iterator to the beginning. More... | |
| const_iterator | cbegin () const |
| Returns a constant iterator to the beginning. More... | |
| iterator | end () |
| Returns an iterator to the end. More... | |
| const_iterator | end () const |
| Returns a constant iterator to the end. More... | |
| const_iterator | cend () const |
| Returns a constant iterator to the end. More... | |
| reverse_iterator | rbegin () |
| Returns a reverse iterator to the beginning. More... | |
| const_reverse_iterator | rbegin () const |
| Returns a constant reverse iterator to the beginning. More... | |
| const_reverse_iterator | crbegin () const |
| Returns a reverse iterator to the beginning. More... | |
| reverse_iterator | rend () |
| Returns a reverse iterator to the end. More... | |
| const_reverse_iterator | rend () const |
| Returns a constant reverse iterator to the end. More... | |
| const_reverse_iterator | crend () const |
| Returns a constant reverse iterator to the end. More... | |
Element access | |
| reference | operator[] (size_type i) |
| Access specified element. More... | |
| const_reference | operator[] (size_type i) const |
| Access specified element. More... | |
| reference | at (size_type i) |
| Access specified element with bounds checking. More... | |
| const_reference | at (size_type i) const |
| Access specified element with bounds checking. More... | |
| reference | front () |
| Access the first array element. More... | |
| constexpr const_reference | front () const |
| Access the first array element. More... | |
| reference | back () |
| Access the last array element. More... | |
| constexpr const_reference | back () const |
| Access the last array element. More... | |
Swap | |
| void | swap (array< T, N > &y) |
| Swaps the container contents. More... | |
Direct access to data | |
| const T * | data () const |
| Direct access to the underlying array. More... | |
| T * | data () |
| Direct access to the underlying array. More... | |
| T * | c_array () |
| Direct access to the underlying array. More... | |
Assignment with type conversion | |
| template<typename T2 > | |
| array< T, N > & | operator= (const array< T2, N > &rhs) |
| Overwrites element of the array with elements of another array. More... | |
| void | assign (const T &value) |
| Assign one value to all elements. More... | |
| void | fill (const T &value) |
| Assign one value to all elements. More... | |
Static Public Member Functions | |
Capacity | |
| static constexpr size_type | size () |
| Returns the number of elements. More... | |
| static constexpr bool | empty () |
| Checks whether the container is empty. More... | |
| static constexpr size_type | max_size () |
| Returns the maximum possible number of elements. More... | |
Check range | |
| static constexpr bool | rangecheck (size_type i) |
| Check range. More... | |
Public Attributes | |
| T | elems [N] |
| Underlying fixed-size array of elements of type T. More... | |
A container that encapsulates fixed size arrays.
This class represents a container that encapsulates fixed size arrays.
It has the same semantics as a struct holding a C-style array T[N]. Unlike a C-style array, it doesn't decay to T* automatically.
The class combines the performance of a C-style array with the convenience of a standard container.
There is a special case for a zero-length array (N == 0). In that case, array.begin() == array.end(), which is some unique value.
Not thread safe
| T | The array value type |
| N | The array size |
See Also std::vector
| typedef const T* boost::array< T, N >::const_iterator |
Constant iterator to array, i.e. a pointer.
| typedef const T& boost::array< T, N >::const_reference |
Constant reference to value type.
| typedef std::reverse_iterator<const_iterator> boost::array< T, N >::const_reverse_iterator |
Constant reverse array iterator - std::reverse_iterator<const_iterator>
| typedef std::ptrdiff_t boost::array< T, N >::difference_type |
Type used to represent distance between iterators.
| typedef T* boost::array< T, N >::iterator |
Iterator to C-style array, i.e. a pointer.
| typedef T& boost::array< T, N >::reference |
Reference to value type.
| typedef std::reverse_iterator<iterator> boost::array< T, N >::reverse_iterator |
Reverse array iterator - std::reverse_iterator<iterator>
| typedef std::size_t boost::array< T, N >::size_type |
Type used to represent array size.
| typedef T boost::array< T, N >::value_type |
The array value type.
| void boost::array< T, N >::assign | ( | const T & | value | ) |
| reference boost::array< T, N >::at | ( | size_type | i | ) |
Access specified element with bounds checking.
This function Returns a reference to the element at specified location i, with bounds checking.
If pos is not within the range of the container, an exception of type std::out_of_range is thrown.
Constant
!(i < size())
std::out_of_range if !(i < size()).
| i | Position of the element to return |
See Also operator[]
| const_reference boost::array< T, N >::at | ( | size_type | i | ) | const |
Access specified element with bounds checking.
This function Returns a reference to the element at specified location i, with bounds checking.
If pos is not within the range of the container, an exception of type std::out_of_range is thrown.
This overload gets called when this is constant.
Constant
!(i < size())
std::out_of_range if !(i < size()).
| i | Position of the element to return |
See Also operator[]
| reference boost::array< T, N >::back | ( | ) |
Access the last array element.
This function returns a reference to the last element in the container.
Calling front on an empty container is undefined.
Constant
c.back() is equivalent to *stdprev(c.end())
!(empty())
See Also operator[], at, begin, end
|
constexpr |
Access the last array element.
This function returns a reference to the last element in the container.
Calling front on an empty container is undefined.
This overload gets called when this is constant.
Constant
c.back() is equivalent to *stdprev(c.end())
!(empty())
See Also operator[], at, begin, end
| iterator boost::array< T, N >::begin | ( | ) |
Returns an iterator to the beginning.
This function returns an iterator to the first element of the array.
Constant
If the array is empty, the returned iterator will be equal to end()
See Also end
| const_iterator boost::array< T, N >::begin | ( | ) | const |
Returns a constant iterator to the beginning.
This function returns a constant iterator to the first element of the array. This is the overload that gets called when this is constant.
Constant
If the array is empty, the returned iterator will be equal to end()
See Also end
| T * boost::array< T, N >::c_array | ( | ) |
Direct access to the underlying array.
Returns pointer to the underlying array serving as element storage.
Constant
The pointer is such that range [data(); data() + size()) is always a valid range, even if the container is empty.
When the container is empty, data() is not dereferenceable.
If size() is 0, data() may or may not return a null pointer.
This function is not available in std::array
For non-empty containers, the returned pointer compares equal to the address of the first element.
| const_iterator boost::array< T, N >::cbegin | ( | ) | const |
Returns a constant iterator to the beginning.
This function returns a constant iterator to the first element of the array.
This function is usually called to provide a constant iterator when this is not constant.
Constant
If the array is empty, the returned iterator will be equal to end()
@return Iterator to the first element of the array
See Also end
| const_iterator boost::array< T, N >::cend | ( | ) | const |
Returns a constant iterator to the end.
This function returns a constant iterator to the element following the last element of the array.
This function is usually called to provide a constant iterator when this is not constant.
Constant
If the array is empty, the returned iterator will be equal to end()
See Also cbegin
| const_reverse_iterator boost::array< T, N >::crbegin | ( | ) | const |
Returns a reverse iterator to the beginning.
Returns a reverse iterator to the first element of the reversed array.
This reverse iterator corresponds to the last element of the non-reversed array.
This function is usually called to provide a constant iterator when this is not constant.
Constant
If the array is empty, the returned iterator is equal to rend().
See Also rend
| const_reverse_iterator boost::array< T, N >::crend | ( | ) | const |
Returns a constant reverse iterator to the end.
Returns a reverse iterator to the element following the last element of the reversed array.
This iterator corresponds to the element preceding the first element of the non-reversed array.
This element acts as a placeholder. Attempting to access it results in undefined behavior.
This function is usually called to provide a constant iterator when this is not constant.
Constant
If the array is empty, the returned iterator is equal to rend().
See Also rend
| T * boost::array< T, N >::data | ( | ) |
Direct access to the underlying array.
Returns pointer to the underlying array serving as element storage.
Constant
The pointer is such that range [data(); data() + size()) is always a valid range, even if the container is empty.
When the container is empty, data() is not dereferenceable.
If size() is 0, data() may or may not return a null pointer.
For non-empty containers, the returned pointer compares equal to the address of the first element.
| const T * boost::array< T, N >::data | ( | ) | const |
Direct access to the underlying array.
Returns pointer to the underlying array serving as element storage.
This overload gets called when this is constant.
Constant
The pointer is such that range [data(); data() + size()) is always a valid range, even if the container is empty.
When the container is empty, data() is not dereferenceable.
If size() is 0, data() may or may not return a null pointer.
For non-empty containers, the returned pointer compares equal to the address of the first element.
|
staticconstexpr |
| iterator boost::array< T, N >::end | ( | ) |
Returns an iterator to the end.
This function returns an iterator to the element following the last element of the array
Constant
If the array is empty, the returned iterator will be equal to end()
See Also begin
| const_iterator boost::array< T, N >::end | ( | ) | const |
Returns a constant iterator to the end.
This function returns a constant iterator to the first element of the array.
This function overload gets called when this is constant.
Constant
If the array is empty, the returned iterator will be equal to end()
See Also begin
| void boost::array< T, N >::fill | ( | const T & | value | ) |
Assign one value to all elements.
This function assigns the same value to all arrays elements
Linear
This function is not available in std::array
See Also operator=
| reference boost::array< T, N >::front | ( | ) |
Access the first array element.
This function returns a reference to the first element in the container.
Calling front on an empty container is undefined.
Constant
c.front() is equivalent to *c.begin()
!(empty())
See Also operator[], at, begin, end
|
constexpr |
Access the first array element.
This function returns a reference to the first element in the container.
Calling front on an empty container is undefined.
This overload gets called when this is constant.
Constant
c.front() is equivalent to *c.begin()
!(empty())
See Also operator[], at, begin, end
|
staticconstexpr |
Returns the maximum possible number of elements.
Returns the maximum number of elements the container is able to hold due to system or library implementation limitations
Constant
Because array<T, N> is a fixed-size container, the value returned by max_size() is equivalent to size()
| array< T, N > & boost::array< T, N >::operator= | ( | const array< T2, N > & | rhs | ) |
Overwrites element of the array with elements of another array.
This function overwrites every element of the this array with the corresponding elements of another array
Linear
this arraySee Also assign
| reference boost::array< T, N >::operator[] | ( | size_type | i | ) |
Access specified element.
This function Returns a reference to the element at specified location i.
No bounds checking is performed.
Constant
!(i < size())
Unlike std::map::operator[], this operator never inserts a new element into the container.
Accessing a nonexistent element through this operator is undefined behavior.
| i | Position of the element to return |
See Also at
| const_reference boost::array< T, N >::operator[] | ( | size_type | i | ) | const |
Access specified element.
This function Returns a reference to the element at specified location i.
No bounds checking is performed.
This overload gets called when this is constant.
Constant
!(i < size())
Unlike std::map::operator[], this operator never inserts a new element into the container.
Accessing a nonexistent element through this operator is undefined behavior.
| i | Position of the element to return |
See Also at
|
staticconstexpr |
Check range.
This function checks if i in the valid range for the array.
This function may be private because it is static.
Constant
Throws std::out_of_range if i is not in the valid range.
This function is not available in std::array
| reverse_iterator boost::array< T, N >::rbegin | ( | ) |
Returns a reverse iterator to the beginning.
Returns a reverse iterator to the first element of the reversed array.
This reverse iterator corresponds to the last element of the non-reversed array.
Constant
If the array is empty, the returned iterator is equal to rend().
See Also rend
| const_reverse_iterator boost::array< T, N >::rbegin | ( | ) | const |
Returns a constant reverse iterator to the beginning.
Returns a reverse iterator to the first element of the reversed array.
This reverse iterator corresponds to the last element of the non-reversed array.
This function overload gets called when this is constant.
Constant
If the array is empty, the returned iterator is equal to rend().
See Also rend
| reverse_iterator boost::array< T, N >::rend | ( | ) |
Returns a reverse iterator to the end.
Returns a reverse iterator to the element following the last element of the reversed array.
This iterator corresponds to the element preceding the first element of the non-reversed array.
This element acts as a placeholder. Attempting to access it results in undefined behavior.
Constant
If the array is empty, the returned iterator is equal to rend().
See Also rend
| const_reverse_iterator boost::array< T, N >::rend | ( | ) | const |
Returns a constant reverse iterator to the end.
Returns a reverse iterator to the element following the last element of the reversed array.
This iterator corresponds to the element preceding the first element of the non-reversed array.
This element acts as a placeholder. Attempting to access it results in undefined behavior.
This function overload gets called when this is constant.
Constant
If the array is empty, the returned iterator is equal to rend().
See Also rend
|
staticconstexpr |
| void boost::array< T, N >::swap | ( | array< T, N > & | y | ) |
Swaps the container contents.
Exchanges the contents of the container with those of other.
This function does not cause iterators and references to associate with the other container.
Linear
Because array<T, N> is not dynamically allocated, this operation has linear complexity.
| y | container to exchange the contents with |
See Also fill, std::swap
| T boost::array< T, N >::elems[N] |
Underlying fixed-size array of elements of type T.