Calico
|
CRTP base type for defining an mutable, iterable container. More...
#include <iterator.hpp>
Public Types | |
typedef ConstIterator | const_iterator |
Const iterator type. | |
typedef std::iterator_traits < const_iterator >::pointer | const_pointer |
Const pointer type. | |
typedef std::iterator_traits < const_iterator >::reference | const_reference |
Const reference type. | |
typedef std::reverse_iterator < const_iterator > | const_reverse_iterator |
Const reverse iterator. | |
typedef std::common_type < std::iterator_traits < const_iterator > ::difference_type, std::iterator_traits< iterator > ::difference_type >::type | difference_type |
Difference type. | |
typedef Iterator | iterator |
Iterator type. | |
typedef std::iterator_traits < iterator >::pointer | pointer |
Pointer type. | |
typedef std::iterator_traits < iterator >::reference | reference |
Reference type. | |
typedef std::reverse_iterator < iterator > | reverse_iterator |
Reverse iterator. | |
typedef Size | size_type |
Size type. | |
typedef std::common_type < std::iterator_traits < const_iterator >::value_type, std::iterator_traits< iterator > ::value_type >::type | value_type |
Value type. | |
Public Member Functions | |
const_reference | at (size_type index) const |
Accesses the element at a given index with bounds-checking. More... | |
reference | at (size_type index) |
Accesses the element at a given index with bounds-checking. More... | |
const_reference | back () const |
Returns a const_reference to the last element in the container. More... | |
reference | back () |
Returns a reference to the last element in the container. More... | |
iterator | begin () |
Returns an iterator to the beginning of the container. More... | |
const_iterator | begin () const |
Returns a const_iterator to the beginning of the container. More... | |
const_iterator | cbegin () const |
Returns a const_iterator to the beginning of the container. More... | |
const_iterator | cend () const |
Returns a const_iterator to the end of the container. More... | |
const_reverse_iterator | crbegin () const |
Returns a const_reverse_iterator to the beginning of the container. More... | |
const_reverse_iterator | crend () const |
Returns a const_reverse_iterator to the end of the container. More... | |
bool | empty () const |
Returns whether the container is empty. More... | |
iterator | end () |
Returns an iterator to the end of the container. More... | |
const_iterator | end () const |
Returns a const_iterator to the end of the container. More... | |
const_reference | front () const |
Returns a const_reference to the first element in the container. More... | |
reference | front () |
Returns a reference to the first element in the container. More... | |
const_reference | operator[] (size_type index) const |
Accesses the element at a given index. More... | |
reference | operator[] (size_type index) |
Accesses the element at a given index. More... | |
reverse_iterator | rbegin () |
Returns a const_reverse_iterator to the beginning of the container. More... | |
const_reverse_iterator | rbegin () const |
Returns a const_reverse_iterator to the beginning of the container. More... | |
reverse_iterator | rend () |
Returns a const_reverse_iterator to the end of the container. More... | |
const_reverse_iterator | rend () const |
Returns a const_reverse_iterator to the end of the container. More... | |
size_type | size () const |
Returns the number of elements in the container. More... | |
Protected Member Functions | |
iterator | _begin () |
Returns an iterator to the beginning of the container. More... | |
iterator | _end () |
Returns an iterator to the end of the container. More... | |
CRTP base type for defining an mutable, iterable container.
Derived | The derived type. |
ConstIterator | An iterator type for read-only access. |
Iterator | An iterator type that is convertible to ConstIterator . If the container is immutable, it must be the same as ConstIterator . |
Size | The size type. Defaults to the common_type of the unsigned difference_type s of the iterators. |
The Derived
type must override certain methods in order for this base type to work correctly. It must provide each of the following at minimum:
data
(equivalent to _begin
)_begin
begin const
and begin
(the latter is optional if the container is immutable).size
_end
end const
and end
(the latter is optional if the container is immutable).The listing below shows the dependencies of each function defined by the base type. The arrow (<==
) may be read as "depends on". Any of these functions may be overridden to customize the behavior of the container.
Note: Keep in mind that if the Derived
type defines a function, the name of the function becomes shadowed so all overloads of this function provided by the base type become unavailable unless explicitly imported via a using
declaration.
|
inlineprotected |
|
inlineprotected |
|
inline |
Accesses the element at a given index with bounds-checking.
Depends on operator[] const
.
|
inline |
Accesses the element at a given index with bounds-checking.
Depends on operator[]
.
|
inline |
Returns a const_reference
to the last element in the container.
Depends on end() const
and is only defined if the iterator is bidirectional. If the container is empty, the result is undefined.
|
inline |
Returns a reference
to the last element in the container.
Depends on end()
and is only defined if the iterator is bidirectional. If the container is empty, the result is undefined.
|
inline |
Returns an iterator
to the beginning of the container.
Depends on _begin()
.
|
inline |
Returns a const_iterator
to the beginning of the container.
Depends on the non-const begin()
and uses a const_cast
.
|
inline |
Returns a const_iterator
to the beginning of the container.
Depends on begin() const
.
|
inline |
Returns a const_iterator
to the end of the container.
Depends on end() const
.
|
inline |
Returns a const_reverse_iterator
to the beginning of the container.
Depends on rbegin() const
.
|
inline |
Returns a const_reverse_iterator
to the end of the container.
Depends on rend() const
.
|
inline |
Returns whether the container is empty.
Depends on begin() const
and end() const
.
|
inline |
Returns an iterator
to the end of the container.
Depends on _end()
.
|
inline |
Returns a const_iterator
to the end of the container.
Depends on the non-const end()
and uses a const_cast
.
|
inline |
Returns a const_reference
to the first element in the container.
Depends on begin() const
. If the container is empty, the result is undefined.
|
inline |
Returns a reference
to the first element in the container.
Depends on begin()
. If the container is empty, the result is undefined.
|
inline |
Accesses the element at a given index.
Depends on begin() const
and calls std::advance
with ADL.
|
inline |
Accesses the element at a given index.
Depends on begin()
and calls std::advance
with ADL.
|
inline |
Returns a const_reverse_iterator
to the beginning of the container.
Depends on end()
.
|
inline |
Returns a const_reverse_iterator
to the beginning of the container.
Depends on end() const
.
|
inline |
Returns a const_reverse_iterator
to the end of the container.
Depends on begin()
.
|
inline |
Returns a const_reverse_iterator
to the end of the container.
Depends on begin() const
.
|
inline |
Returns the number of elements in the container.
Depends on begin() const
and end() const
and calls std::distance()
with ADL.