# stl_algobase.h File Reference

## Detailed Description

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

Definition in file stl_algobase.h.

Go to the source code of this file.

## Namespaces

- namespace std

## Defines

- #define _ALGOBASE_H

## Functions

- template<typename _II, typename _OI> _OI __copy_aux (_II __first, _II __last, _OI __result)
- template<typename _BI1, typename _BI2> _BI2 __copy_backward_aux (_BI1 __first, _BI1 __last, _BI2 __result)
- template<typename _InputIterator, typename _OutputIterator> _OutputIterator copy (_InputIterator __first, _InputIterator __last, _OutputIterator __result)
- template<typename _BI1, typename _BI2> _BI2 copy_backward (_BI1 __first, _BI1 __last, _BI2 __result)
- template<typename _InputIterator1, typename _InputIterator2, typename _BinaryPredicate> bool equal (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __binary_pred)
- template<typename _InputIterator1, typename _InputIterator2> bool equal (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2)
- void fill (char *__first, char *__last, const char &__c)
- void fill (signed char *__first, signed char *__last, const signed char &__c)
- void fill (unsigned char *__first, unsigned char *__last, const unsigned char &__c)
- template<typename _ForwardIterator, typename _Tp> void fill (_ForwardIterator __first, _ForwardIterator __last, const _Tp &__value)
- template<typename _Size> char * fill_n (char *__first, _Size __n, const char &__c)
- template<typename _Size> signed char * fill_n (char *__first, _Size __n, const signed char &__c)
- template<typename _Size> unsigned char * fill_n (unsigned char *__first, _Size __n, const unsigned char &__c)
- template<typename _OutputIterator, typename _Size, typename _Tp> _OutputIterator fill_n (_OutputIterator __first, _Size __n, const _Tp &__value)
- template<typename _ForwardIterator1, typename _ForwardIterator2> void iter_swap (_ForwardIterator1 __a, _ForwardIterator2 __b)
- bool lexicographical_compare (const char *__first1, const char *__last1, const char *__first2, const char *__last2)
- bool lexicographical_compare (const unsigned char *__first1, const unsigned char *__last1, const unsigned char *__first2, const unsigned char *__last2)
- template<typename _InputIterator1, typename _InputIterator2, typename _Compare> bool lexicographical_compare (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
- template<typename _InputIterator1, typename _InputIterator2> bool lexicographical_compare (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2)
- template<typename _Tp, typename _Compare> const _Tp & max (const _Tp &__a, const _Tp &__b, _Compare __comp)
- template<typename _Tp> const _Tp & max (const _Tp &__a, const _Tp &__b)
- template<typename _Tp, typename _Compare> const _Tp & min (const _Tp &__a, const _Tp &__b, _Compare __comp)
- template<typename _Tp> const _Tp & min (const _Tp &__a, const _Tp &__b)
- template<typename _InputIterator1, typename _InputIterator2, typename _BinaryPredicate> pair< _InputIterator1, _InputIterator2 > mismatch (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __binary_pred)
- template<typename _InputIterator1, typename _InputIterator2> pair< _InputIterator1, _InputIterator2 > mismatch (_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2)
- template<typename _Tp> void swap (_Tp &__a, _Tp &__b)

## Function Documentation

_OutputIterator std::copy | ( | _InputIterator | __first,
|  | _InputIterator | __last,
|  | _OutputIterator | __result
| ) | `[inline]`

Copies the range [first,last) into result.

Parameters:

  | first | An input iterator.
  | last | An input iterator.
  | result | An output iterator.

Returns:
  result + (first - last)

This inline function will boil down to a call to `memmove` whenever possible. Failing that, if random access iterators are passed, then the loop count will be known (and therefore a candidate for compiler optimizations such as unrolling). Result may not be contained within [first,last); the copy_backward function should be used instead.

Note that the end of the output range is permitted to be contained within [first,last).

Definition at line 375 of file stl_algobase.h.

References __gnu_cxx::copy_n().

Referenced by codecvt< _InternT, _ExternT, encoding_state >::do_out(), vector::erase(), deque::erase(), std::merge(), vector::operator=(), deque::operator=(), std::rotate_copy(), std::set_difference(), std::set_symmetric_difference(), std::set_union(), basic_filebuf::underflow(), basic_streambuf::xsgetn(), and basic_streambuf::xsputn().

_BI2 std::copy_backward | ( | _BI1 | __first,
|  | _BI1 | __last,
|  | _BI2 | __result
| ) | `[inline]`

Copies the range [first,last) into result.

Parameters:

  | first | A bidirectional iterator.
  | last | A bidirectional iterator.
  | result | A bidirectional iterator.

Returns:
  result - (first - last)

The function has the same effect as copy, but starts at the end of the range and works its way to the start, returning the start of the result. This inline function will boil down to a call to `memmove` whenever possible. Failing that, if random access iterators are passed, then the loop count will be known (and therefore a candidate for compiler optimizations such as unrolling).

Result may not be in the range [first,last). Use copy instead. Note that the start of the output range may overlap [first,last).

Definition at line 504 of file stl_algobase.h.

Referenced by deque::erase().

bool std::equal | ( | _InputIterator1 | __first1,
|  | _InputIterator1 | __last1,
|  | _InputIterator2 | __first2,
|  | _BinaryPredicate | __binary_pred
| ) | `[inline]`

Tests a range for element-wise equality.

Parameters:

  | first1 | An input iterator.
  | last1 | An input iterator.
  | first2 | An input iterator.
  | binary_pred | A binary predicate functor.

Returns:
  A boolean true or false.

This compares the elements of two ranges using the binary_pred parameter, and returns true or false depending on whether all of the corresponding elements of the ranges are equal.

Definition at line 781 of file stl_algobase.h.

bool std::equal | ( | _InputIterator1 | __first1,
|  | _InputIterator1 | __last1,
|  | _InputIterator2 | __first2
| ) | `[inline]`

Tests a range for element-wise equality.

Parameters:

  | first1 | An input iterator.
  | last1 | An input iterator.
  | first2 | An input iterator.

Returns:
  A boolean true or false.

This compares the elements of two ranges using `==` and returns true or false depending on whether all of the corresponding elements of the ranges are equal.

Definition at line 748 of file stl_algobase.h.

Referenced by std::operator==().

void std::fill | ( | _ForwardIterator | __first,
|  | _ForwardIterator | __last,
|  | const _Tp & | __value
| ) |

Fills the range [first,last) with copies of value.

Parameters:

  | first | A forward iterator.
  | last | A forward iterator.
  | value | A reference-to-const of arbitrary type.

Returns:
  Nothing.

This function fills a range with copies of the same value. For one-byte types filling contiguous areas of memory, this becomes an inline call to `memset`.

Definition at line 560 of file stl_algobase.h.

_OutputIterator std::fill_n | ( | _OutputIterator | __first,
|  | _Size | __n,
|  | const _Tp & | __value
| ) |

Fills the range [first,first+n) with copies of value.

Parameters:

  | first | An output iterator.
  | n | The count of copies to perform.
  | value | A reference-to-const of arbitrary type.

Returns:
  The iterator at first+n.

This function fills a range with copies of the same value. For one-byte types filling contiguous areas of memory, this becomes an inline call to `memset`.

Definition at line 636 of file stl_algobase.h.

void std::iter_swap | ( | _ForwardIterator1 | __a,
|  | _ForwardIterator2 | __b
| ) | `[inline]`

Swaps the contents of two iterators.

Parameters:

  | a | An iterator.
  | b | Another iterator.

Returns:
  Nothing.

This function swaps the values pointed to by two iterators, not the iterators themselves.

Definition at line 142 of file stl_algobase.h.

Referenced by std::next_permutation(), std::prev_permutation(), std::random_shuffle(), and std::swap_ranges().

bool std::lexicographical_compare | ( | _InputIterator1 | __first1,
|  | _InputIterator1 | __last1,
|  | _InputIterator2 | __first2,
|  | _InputIterator2 | __last2,
|  | _Compare | __comp
| ) |

Performs "dictionary" comparison on ranges.

Parameters:

  | first1 | An input iterator.
  | last1 | An input iterator.
  | first2 | An input iterator.
  | last2 | An input iterator.
  | comp | A comparison functor.

Returns:
  A boolean true or false.

The same as the four-parameter `lexigraphical_compare`, but uses the comp parameter instead of `<`.

Definition at line 853 of file stl_algobase.h.

bool std::lexicographical_compare | ( | _InputIterator1 | __first1,
|  | _InputIterator1 | __last1,
|  | _InputIterator2 | __first2,
|  | _InputIterator2 | __last2
| ) |

Performs "dictionary" comparison on ranges.

Parameters:

  | first1 | An input iterator.
  | last1 | An input iterator.
  | first2 | An input iterator.
  | last2 | An input iterator.

Returns:
  A boolean true or false.

"Returns true if the sequence of elements defined by the range [first1,last1) is lexicographically less than the sequence of elements defined by the range [first2,last2). Returns false otherwise." (Quoted from [25.3.8]/1.) If the iterators are all character pointers, then this is an inline call to `memcmp`.

Definition at line 812 of file stl_algobase.h.

Referenced by std::operator<().

const _Tp& std::max | ( | const _Tp & | __a,
|  | const _Tp & | __b,
|  | _Compare | __comp
| ) | `[inline]`

This does what you think it does.

Parameters:

  | a | A thing of arbitrary type.
  | b | Another thing of arbitrary type.
  | comp | A comparison functor.

Returns:
  The greater of the parameters.

This will work on temporary expressions, since they are only evaluated once, unlike a preprocessor macro.

Definition at line 248 of file stl_algobase.h.

const _Tp& std::max | ( | const _Tp & | __a,
|  | const _Tp & | __b
| ) | `[inline]`

This does what you think it does.

Parameters:

  | a | A thing of arbitrary type.
  | b | Another thing of arbitrary type.

Returns:
  The greater of the parameters.

This is the simple classic generic implementation. It will work on temporary expressions, since they are only evaluated once, unlike a preprocessor macro.

Definition at line 206 of file stl_algobase.h.

Referenced by basic_istream::ignore(), std::operator>>(), basic_istream::operator>>(), and basic_stringbuf::overflow().

const _Tp& std::min | ( | const _Tp & | __a,
|  | const _Tp & | __b,
|  | _Compare | __comp
| ) | `[inline]`

This does what you think it does.

Parameters:

  | a | A thing of arbitrary type.
  | b | Another thing of arbitrary type.
  | comp | A comparison functor.

Returns:
  The lesser of the parameters.

This will work on temporary expressions, since they are only evaluated once, unlike a preprocessor macro.

Definition at line 228 of file stl_algobase.h.

const _Tp& std::min | ( | const _Tp & | __a,
|  | const _Tp & | __b
| ) | `[inline]`

This does what you think it does.

Parameters:

  | a | A thing of arbitrary type.
  | b | Another thing of arbitrary type.

Returns:
  The lesser of the parameters.

This is the simple classic generic implementation. It will work on temporary expressions, since they are only evaluated once, unlike a preprocessor macro.

Definition at line 184 of file stl_algobase.h.

Referenced by basic_string::compare(), basic_string< char >::compare(), basic_istream::ignore(), basic_istream::operator>>(), basic_stringbuf::overflow(), __gnu_cxx::random_sample_n(), basic_istream::readsome(), basic_string::rfind(), basic_filebuf::underflow(), basic_streambuf::xsgetn(), and basic_streambuf::xsputn().

pair<_InputIterator1, _InputIterator2> std::mismatch | ( | _InputIterator1 | __first1,
|  | _InputIterator1 | __last1,
|  | _InputIterator2 | __first2,
|  | _BinaryPredicate | __binary_pred
| ) |

Finds the places in ranges which don't match.

Parameters:

  | first1 | An input iterator.
  | last1 | An input iterator.
  | first2 | An input iterator.
  | binary_pred | A binary predicate functor.

Returns:
  A pair of iterators pointing to the first mismatch.

This compares the elements of two ranges using the binary_pred parameter, and returns a pair of iterators. The first iterator points into the first range, the second iterator points into the second range, and the elements pointed to by the iterators are not equal.

Definition at line 719 of file stl_algobase.h.

pair<_InputIterator1, _InputIterator2> std::mismatch | ( | _InputIterator1 | __first1,
|  | _InputIterator1 | __last1,
|  | _InputIterator2 | __first2
| ) |

Finds the places in ranges which don't match.

Parameters:

  | first1 | An input iterator.
  | last1 | An input iterator.
  | first2 | An input iterator.

Returns:
  A pair of iterators pointing to the first mismatch.

This compares the elements of two ranges using `==` and returns a pair of iterators. The first iterator points into the first range, the second iterator points into the second range, and the elements pointed to by the iterators are not equal.

Definition at line 683 of file stl_algobase.h.

void std::swap | ( | _Tp & | __a,
|  | _Tp & | __b
| ) | `[inline]`

Swaps two values.

Parameters:

  | a | A thing of arbitrary type.
  | b | Another thing of arbitrary type.

Returns:
  Nothing.

This is the simple classic generic implementation. It will work on any type which has a copy constructor and an assignment operator.

Definition at line 92 of file stl_algobase.h.