Skip to content
Ned Bingham edited this page Apr 1, 2017 · 4 revisions

std/slice.h


slice

  • struct iterator : container::iterator

This structure inherits the base container's 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::iterator::type iter_type is a quick alias to the wrapped iterator.
  • typedef elem_type<container::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

iterator()

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

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

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

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

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

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

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

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

void swap(iterator i)
void swap(const_iterator i)

swap the values between these two iterators. The iterators are left unchanged.

iterator &operator=(iterator i)

set the base iterator equal to another.

Simple Containers

Standard Containers

Interface Containers

Specialized Containers

Input/Output

Algorithm

Clone this wiki locally