c++ - Is there a function like find_last_of in std but not in string?
问题描述
I know there is function
string::find_last_of
But I want to process a large chunk of char* data. I don't want to assign the char* to a string.
I know there is a std function
std::find
But it only can find char* on positive sequence. Is there such a way to find in reverse order? If not in std, is there a way in boost?
解决方案
在范围 [first, last) 中搜索元素 [s_first, s_last) 的最后一个子序列。
例如
#include <algorithm>
char *data = ...;
char *data_end = data + size;
char toFind = ...;
char *pfind = &toFind;
char *found = std::find_end(data, data_end, pfind, pfind + 1);
if (found != data_end)
...
推荐阅读
- go - 调用垃圾收集器后程序卡在函数调用中
- laravel - 使用 laravel 控制器检查至少一个输入是否具有值
- javascript - 从 html 中获取 Checkbox 数据以将其保存在 Google 表格中
- android - 使用 Provider 从第二个屏幕更新 Scaffold
- c++ - 在 Visual Studio 2013 中使用 Boost.Json 库
- reactjs - 如何使用反应更改组件中传输的值的值?
- python - python selenium 无法找到谷歌地图术语和服务的元素
- macos - 如何使用 windows Visual Studio 发布到 MacOS
- javascript - 当每个步骤可用时,如何进行链式提取并显示结果?
- python - 在python中使用快速排序对链表进行排序