# stl_iterator_base_funcs.h File Reference

## Detailed Description

This is an internal header file, included by other library headers. You should not attempt to use it directly.

This file contains all of the general iterator-related utility functions, such as distance() and advance().

Definition in file stl_iterator_base_funcs.h.

Go to the source code of this file.

## Namespaces

- namespace std

## Defines

- #define _ITERATOR_BASE_FUNCS_H

## Functions

- template<typename _RandomAccessIterator, typename _Distance> void __advance (_RandomAccessIterator &__i, _Distance __n, random_access_iterator_tag)
- template<typename _BidirectionalIterator, typename _Distance> void __advance (_BidirectionalIterator &__i, _Distance __n, bidirectional_iterator_tag)
- template<typename _InputIterator, typename _Distance> void __advance (_InputIterator &__i, _Distance __n, input_iterator_tag)
- template<typename _RandomAccessIterator> iterator_traits< _RandomAccessIterator
  >::difference_type __distance (_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag)
- template<typename _InputIterator> iterator_traits< _InputIterator
  >::difference_type __distance (_InputIterator __first, _InputIterator __last, input_iterator_tag)
- template<typename _InputIterator, typename _Distance> void advance (_InputIterator &__i, _Distance __n)
- template<typename _InputIterator> iterator_traits< _InputIterator
  >::difference_type distance (_InputIterator __first, _InputIterator __last)

## Function Documentation

void std::advance | ( | _InputIterator & | __i,
|  | _Distance | __n
| ) | `[inline]`

A generalization of pointer arithmetic.

Parameters:

  | i | An input iterator.
  | n | The "delta" by which to change `i`.

Returns:
  Nothing.

This increments `i` by `n`. For bidirectional and random access iterators, `n` may be negative, in which case `i` is decremented.

For random access iterators, this uses their `+` and `-` operations and are constant time. For other iterator classes they are linear time.

Definition at line 172 of file stl_iterator_base_funcs.h.

Referenced by std::equal_range(), std::lower_bound(), and std::upper_bound().

iterator_traits<_InputIterator>::difference_type std::distance | ( | _InputIterator | __first,
|  | _InputIterator | __last
| ) | `[inline]`

A generalization of pointer arithmetic.

Parameters:

  | first | An input iterator.
  | last | An input iterator.

Returns:
  The distance between them.

Returns `n` such that first + n == last. This requires that `last` must be reachable from `first`. Note that `n` may be negative.

For random access iterators, this uses their `+` and `-` operations and are constant time. For other iterator classes they are linear time.

Definition at line 114 of file stl_iterator_base_funcs.h.

Referenced by std::equal_range(), std::inplace_merge(), std::lower_bound(), __gnu_cxx::random_sample_n(), list::size(), and std::upper_bound().