Boost C++ 库

“...世界上最受尊敬和设计最精良的 C++ 库项目之一。” Herb SutterAndrei Alexandrescu, C++ 编码标准

PrevUpHomeNext

函数 replace_nth_copy

boost::algorithm::replace_nth_copy — 替换第 n 个算法。

概要

// In header: <boost/algorithm/string/replace.hpp>


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);

描述

使用格式字符串替换输入中搜索字符串的第 N 个(从零开始索引)匹配项。 结果是输入的修改副本。 它作为序列返回或复制到输出迭代器。

[Note] 注意

此函数的第二种变体提供了强大的异常安全保证

参数

输出

一个输出迭代器,结果将被复制到该迭代器

输入

一个输入字符串

搜索

要搜索的子字符串

Nth

要替换的匹配项的索引。 索引从 0 开始。 对于负 N,匹配项从字符串末尾开始计数。

格式

一个替换字符串

返回

一个输出迭代器,指向最后一个插入的字符之后,或输入的修改副本


PrevUpHomeNext