名稱空間
變體
操作

std::basic_string_view<CharT,Traits>::find_first_not_of

來自 cppreference.com
 
 
 
 
constexpr size_type
    find_first_not_of( basic_string_view v, size_type pos = 0 ) const noexcept;
(1) (C++17 起)
constexpr size_type
    find_first_not_of( CharT ch, size_type pos = 0 ) const noexcept;
(2) (C++17 起)
constexpr size_type
    find_first_not_of( const CharT* s, size_type pos, size_type count ) const;
(3) (C++17 起)
constexpr size_type
    find_first_not_of( const CharT* s, size_type pos = 0 ) const;
(4) (C++17 起)

查詢第一個不等於給定字元序列中任何字元的字元。

1) 在此檢視中,從位置 pos 開始,查詢第一個不等於 v 中任何字元的字元。
2) 等價於 find_first_not_of(basic_string_view(std::addressof(ch), 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));
                    //     ^
}

[編輯] 另請參閱

在檢視中查詢字元
(public 成員函式) [編輯]
查詢子串的最後一次出現
(public 成員函式) [編輯]
查詢字元的首次出現
(public 成員函式) [編輯]
查詢字元的最後一次出現
(public 成員函式) [編輯]
查詢字元的最後一次缺席
(public 成員函式) [編輯]
查詢字元的首次缺席
(std::basic_string<CharT,Traits,Allocator> 的 public 成員函式) [編輯]