std::basic_string_view<CharT,Traits>::find_last_not_of
来自 cppreference.cn
< cpp | string | basic string view
constexpr size_type find_last_not_of( basic_string_view v, size_type pos = npos ) const noexcept; |
(1) | (since C++17) |
constexpr size_type find_last_not_of( CharT ch, size_type pos = npos ) const noexcept; |
(2) | (since C++17) |
constexpr size_type find_last_not_of( const CharT* s, size_type pos, size_type count ) const; |
(3) | (since C++17) |
constexpr size_type find_last_not_of( const CharT* s, size_type pos = npos ) const; |
(4) | (since C++17) |
查找最后一个不等于给定字符序列中任何字符的字符。搜索仅考虑区间 [
0,
pos]
。
1) 在此视图中查找最后一个不等于 v 中任何字符的字符,从位置 pos 开始。
2) 等效于 find_last_not_of(basic_string_view(std::addressof(ch), 1), pos)。
3) 等效于 find_last_not_of(basic_string_view(s, count), pos)。
4) 等效于 find_last_not_of(basic_string_view(s), pos)。
目录 |
[编辑] 参数
v | - | 要搜索的视图 |
pos | - | 开始搜索的位置 |
count | - | 要比较的字符串的长度 |
s | - | 指向要比较的字符串的指针 |
ch | - | 要比较的字符 |
[编辑] 返回值
最后一个不等于给定字符串中任何字符的字符的位置;如果未找到此类字符,则为 npos。
[编辑] 复杂度
[编辑] 示例
运行此代码
#include <string_view> using std::operator""sv; int main() { static_assert(1 == "BCDEF"sv.find_last_not_of("DEF")); // ^ static_assert(2 == "BCDEFG"sv.find_last_not_of("EFG", 3)); // ^ static_assert(2 == "ABBA"sv.find_last_not_of('A')); // ^ static_assert(1 == "ABBA"sv.find_last_not_of('A', 1)); // ^ }
[编辑] 参见
在视图中查找字符 (public member function) | |
查找子字符串的最后一次出现 (public member function) | |
查找字符的首次出现 (public member function) | |
查找字符的最后一次出现 (public member function) | |
查找字符的首次缺失 (public member function) | |
查找字符的最后一次缺失 (public member function of std::basic_string<CharT,Traits,Allocator> ) |