std::basic_string_view<CharT,Traits>::find_first_not_of
来自cppreference.com
| |
(1) | (C++17 起) |
| |
(2) | (C++17 起) |
| |
(3) | (C++17 起) |
| |
(4) | (C++17 起) |
寻找首个不等于给定字符序列中任何字符的字符。
1) 在此视图中寻找首个不等于
v 中任意字符的字符,从位置 pos 开始。2) 等价于
find_first_not_of(basic_string_view(std::addressof(c), 1), pos)。3) 等价于
find_first_not_of(basic_string_view(s, count), pos)。4) 等价于
find_first_not_of(basic_string_view(s), pos)。参数
| v | - | 要搜索的视图 |
| pos | - | 要开始搜索的位置 |
| count | - | 要比较的字符串的长度 |
| s | - | 指向要比较的字符串的指针 |
| ch | - | 要比较的字符 |
返回值
首个不等于给定字符串中任意字符的字符位置,或若找不到这些字符则为 std::string_view::npos。
复杂度
最坏情况为 O(size() * v.size())。
示例
运行此代码
#include <string_view>
using namespace std::literals;
int main()
{
static_assert(2 == "BCDEF"sv.find_first_not_of("ABC"));
// ^
static_assert(4 == "BCDEF"sv.find_first_not_of("ABC", 4));
// ^
static_assert(1 == "BCDEF"sv.find_first_not_of('B'));
// ^
static_assert(3 == "BCDEF"sv.find_first_not_of('D', 2));
// ^
}
