Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Function replace_nth_copy

boost::algorithm::replace_nth_copy — Replace nth algorithm.

Synopsis

template<typename OutputIteratorT, typename Range1T, typename Range2T, 
         typename Range3T> 
  OutputIteratorT 
  replace_nth_copy(OutputIteratorT Output, const Range1T & Input, 
                   const Range2T & Search, int Nth, const Range3T & Format);
template<typename SequenceT, typename Range1T, typename Range2T> 
  SequenceT replace_nth_copy(const SequenceT & Input, const Range1T & Search, 
                             int Nth, const Range2T & Format);

Description

Replace an Nth (zero-indexed) match of the search string in the input with the format string. The result is a modified copy of the input. It is returned as a sequence or copied to the output iterator.

Parameters:

Format

A substitute string

Input

An input string

Nth

An index of the match to be replaced. The index is 0-based. For negative N, matches are counted from the end of string.

Output

An output iterator to which the result will be copied

Search

A substring to be searched for

Returns:

An output iterator pointing just after the last inserted character or a modified copy of the input

Notes:

The second variant of this function provides the strong exception-safety guarantee


PrevUpHomeNext