将boost字符串算法与迭代器结合使用
Using boost strings algorithms with iterators
我有一个由2个迭代器定义的字符串。我想检查一下,它是否以字符串结尾。现在我的代码看起来像
algorithm::ends_with(string(begin,end),"format(");
有没有办法在不构造字符串的情况下执行这个函数?类似的东西
algorithm::ends_with(begin,end,"format(");
是。
std::string s = "something";
bool b = boost::algorithm::ends_with( &s[0], "g"); // true
迭代器也可以用于构建范围:
#include <boost/range.hpp>
std::string s = "somet0hing";
std::string::iterator it = s.begin();
bool b = boost::algorithm::ends_with(
boost::make_iterator_range( it, s.end()), "g"); // true
或:
std::string s = "somet0hing";
std::string::iterator it = s.begin();
bool b = boost::algorithm::ends_with( &(*it), "g"); // true
相关文章:
- 使用std::multimap迭代器创建std::list
- 来自 std::list 的迭代器 .end() 按预期返回"0xcdcdcdcdcdcdcdcd"但 .begin()
- C++中带有List类的迭代器Segfault
- 如何在c++迭代器类型中包装std::chrono
- 集合上的输出迭代器:assign和increment迭代器
- Boost Spirit,获取迭代器内部语义动作
- 对于set上的循环-获取next元素迭代器
- 为什么output_editor Concept不需要output_e迭代器标记
- c++17文件系统::recursive_directory迭代器()在mac上没有给出这样的目录,但在windows上
- 使用迭代器时如何访问对象在向量中的位置?
- std::vector::迭代器是否可以合法地作为指针
- 跟随整数索引列表的自定义类迭代器
- 不明白迭代器,引用和指针失效,一个例子
- 我可以使用反向迭代器作为ForwardIt吗
- ESP8266单片机矢量迭代器的C++问题
- 如何在C++中将迭代器作为函数参数传递
- 是否应避免从非常量迭代器转换为常量迭代器?
- 前向迭代器与多个绑定相结合的迭代速度太快
- 如何将基于泛型迭代器的算法与基于实现的算法结合起来?
- 将boost字符串算法与迭代器结合使用