Skip to content

Constant Iterator

Kamil Krauze edited this page Jan 19, 2024 · 7 revisions

Description

This is an iterator type commonly used as an input parameter of functions using iterators that will not have their values changed.

Custom typenames

ValueType = typename stack_vector::ValueType

The type of typename T of stack_vector.

PointerType = ValueType*

The type pointer of typename T of stack_vector.

ReferenceType = ValueType&

The type reference of typename T of stack_vector.


Member Variables

Name Type Visibility Description
m_ptr PointerType private This points to the address of m_data of stack_vector.

Allocation

const_iterator()

Default constructor

const_iterator(PointerType ptr)

Copy constructor which assigns m_ptr to point at the m_data of stack_vector<T>.


Accessor operators

ReferenceType operator[](const size_t index)

Allows to index the array pointed at m_data.

PointerType operator->()

Returns m_ptr.

ReferenceType operator*()

Returns reference to 'm_ptr'.


Arithmetical operators

const_iterator& operator++()

Prefix increment m_ptr.

const_iterator operator++(int)

Postfix increment m_ptr.

const_iterator& operator--()

Prefix decrement m_ptr.

const_iterator operator--(int)

Postfix decrement m_ptr.

const_iterator& operator+=(const size_t val)

Allows for indexing the array easily.

const_iterator operator+(const size_t val)

Allows for indexing the array easily.

const_iterator& operator-=(const size_t val)

Allows for indexing the array easily.

const_iterator operator-(const size_t val)

Allows for indexing the array easily.


Relational Operators

bool operator==(const const_iterator& other)

If m_ptr value is the same as other m_ptr.

bool operator!=(const const_iterator& other)

If m_ptr value is not the same as other m_ptr.

bool operator>=(const const_iterator& other)

If m_ptr value is greater than or equal to other m_ptr.

bool operator<=(const const_iterator& other)

If m_ptr value is less than or equal to other m_ptr.

bool operator>(const const_iterator& other)

If m_ptr value is greater than to other m_ptr.

bool operator<(const const_iterator& other)

If m_ptr value is less than to other m_ptr.