Calico
|
A ForwardIterator
that traverses a null-terminated array.
More...
#include <string.hpp>
Public Types | |
typedef std::ptrdiff_t | difference_type |
Difference type. | |
typedef std::forward_iterator_tag | iterator_category |
Iterator category. | |
typedef value_type * | pointer |
Pointer type. | |
typedef value_type & | reference |
Reference type. | |
typedef T | value_type |
Value type. | |
Public Member Functions | |
null_terminated_iterator (pointer ptr, bool end=false) | |
Constructs a null-terminated iterator from a pointer. More... | |
bool | operator!= (const null_terminated_iterator &other) const |
Compares two iterators for inequality. | |
reference | operator* () const |
Dereferences the iterator. | |
null_terminated_iterator & | operator++ () |
Increments the iterator and returns the incremented iterator. | |
null_terminated_iterator | operator++ (int) |
Increments and returns the iterator prior to the increment. | |
pointer | operator-> () const |
Member access of the element pointed to by the iterator. | |
bool | operator== (const null_terminated_iterator &other) const |
Compares two iterators for equality. | |
A ForwardIterator
that traverses a null-terminated array.
T | The element type of the array. Must be DefaultConstructible , Destructible , and EqualityComparable . |
A null-terminated array is an array of elements in which the past-the-end element is determined by a default-constructed value of the element type. Elements before the past-the-end element are forbidden to have the same value as the default-constructed value. A typical example would be a null-terminated array of char
s (a plain C string).
This iterator allows forward iteration from the first value of the array to the last value of the array, just before the past-the-end element. Elements beyond the past-the-end element are not considered to be part of the null-terminated array.
The construction of this iterator does not require the position of the past-the-end element and thus it has O(1) complexity with respect to the length of the string.
The following actions will invoke undefined behavior:
|
inlineexplicit |
Constructs a null-terminated iterator from a pointer.
ptr | A pointer to the first element. |
end | Whether a past-the-end iterator is to be constructed. |