C++ 参考手册

位置:首页 > C++ 参考手册 >字符串库 >std::basic_string_view > std::basic_string_view<CharT,Traits>::find_last_of

constexpr size_type find_last_of(basic_string_view v, size_type pos = npos) const noexcept;
(1) (C++17 起)
constexpr size_type find_last_of(CharT c, size_type pos = npos) const noexcept;
(2) (C++17 起)
constexpr size_type find_last_of(const CharT* s, size_type pos, size_type count) const;
(3) (C++17 起)
constexpr size_type find_last_of(const CharT* s, size_type pos = npos) const;
(4) (C++17 起)

寻找最后一个给定字符序列中字符之一相等的字符。不指定准确的搜索算法。搜索只考虑区间 [0; pos] 。若区间中不存在字符,则将返回 npos

1) 寻找此视图中 v 的任意字符的最后一次出现,到位置 pos 结束。
2) 等价于 find_last_of(basic_string_view(std::addressof(c), 1), pos)
3) 等价于 find_last_of(basic_string_view(s, count), pos)
4) 等价于 find_last_of(basic_string_view(s), pos)

参数

v - 要搜索的视图
pos - 要开始搜索的位置
count - 要搜索的字符串的长度
s - 指向要搜索的字符串的指针
ch - 要搜索的字符

返回值

子串的任意字符的最后一次出现位置,或者若找不到这些字符则为 npos

复杂度

最坏情况为 O(size() * v.size()) 。

参阅

在视图中查找字符
(公开成员函数)
寻找子串的最后一次出现
(公开成员函数)
查找字符的首次出现
(公开成员函数)
查找字符的首次不出现
(公开成员函数)
查找字符的最后一次不出现
(公开成员函数)