Skip to content

slice const_iterator

Ned Bingham edited this page Apr 1, 2017 · 2 revisions

std/slice.h


slice

  • struct const_iterator : container::const_iterator

This structure inherits the base container's const_iterator which we'll call the base iterator. The base iterator points to another iterator which we'll call the wrapped iterator. This structure effectively makes the base iterator transparent so that interacting with this iterator is like interacting with the wrapped iterator.

Member Types

  • typedef container::const_iterator::type iter_type is a quick alias to the wrapped iterator.
  • typedef elem_type<container::const_iterator::type>::type type is an alias to the wrapped iterator's type so that generic wrappers can access the parent container's value_type

Member Functions

Constructor

const_iterator()

The default constructor calls the default constructor of the base iterator.

const_iterator(const container::iterator &copy)

A copy/conversion constructor calls the copy constructor of the base iterator.

Utility

operator bool() checks the validity of both the base and wrapped iterator.

operator iter_type() a conversion operator to get the wrapped iterator.

Accessors

type &operator*() returns the wrapped iterator's value.

type *operator->() The dot operator for the wrapped iterator's value.

type *ptr() returns a pointer to the wrapped iterator's value.

value &get() returns the wrapped iterator's value.

container::iterator &ref() Returns the base iterator.

Iteration

const_iterator &operator++() Increments to the next base iterator.

const_iterator &operator--() Decrements to the previous base iterator.

const_iterator &operator+=(int n) Increments the base iterator by n.

const_iterator &operator-=(int n) Decrements the base iterator by n.

const_iterator operator+(int n) Returns the base iterator n elements ahead of this one.

const_iterator operator-(int n) Returns the base iterator n elements behind this one.

Comparison

bool operator==(iterator i)
bool operator!=(iterator i)
bool operator==(const_iterator i)
bool operator!=(const_iterator i)

Comparison operations between iterators compares the base iterators.

int operator-(iterator i)
int operator-(const_iterator i)

Returns the number of elements between i and this iterator.

Slicing

slice<container> sub(int length)
slice<container> subcpy(int length)

Returns a slice starting at this iterator for a given length.

slice<container> sub()
slice<container> subcpy()

Returns a slice from this iterator to the end of the container.

Modifiers

const_iterator &operator=(const_iterator i)

set the base iterator equal to another.

Simple Containers

Standard Containers

Interface Containers

Specialized Containers

Input/Output

Algorithm

Clone this wiki locally