std::basic_string_view<CharT,Traits>::find_last_not_of
來自 cppreference.com
< cpp | string | basic string view
constexpr size_type find_last_not_of( basic_string_view v, size_type pos = npos ) const noexcept; |
(1) | (C++17 起) |
constexpr size_type find_last_not_of( CharT ch, size_type pos = npos ) const noexcept; |
(2) | (C++17 起) |
constexpr size_type find_last_not_of( const CharT* s, size_type pos, size_type count ) const; |
(3) | (C++17 起) |
constexpr size_type find_last_not_of( const CharT* s, size_type pos = npos ) const; |
(4) | (C++17 起) |
查詢最後一個不等於給定字元序列中任何字元的字元。搜尋僅考慮區間 [
0,
pos]
。
1) 在此檢視中,從位置 pos 開始,查詢最後一個不等於 v 中任何字元的字元。
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)); // ^ }
[編輯] 參閱
在檢視中查詢字元 (公共成員函式) | |
查詢子串的最後一次出現 (公共成員函式) | |
查詢字元的首次出現 (公共成員函式) | |
查詢字元的最後一次出現 (公共成員函式) | |
查詢字元的首次缺席 (公共成員函式) | |
查詢字元的最後一次缺席 ( std::basic_string<CharT,Traits,Allocator> 的公共成員函式) |