名前空間
変種
操作

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

From 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 - 比較する文字の文字列へのポインタ
文字 - 比較する文字

[編集] 戻り値

指定された文字列のいずれの文字とも等しくない最初の文字の位置。そのような文字が見つからない場合は、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 member function) [編集]
部分文字列が最後に現れる位置を見つける
(public member function) [編集]
文字が最初に現れる位置を見つける
(public member function) [編集]
文字が最後に現れる位置を見つける
(public member function) [編集]
文字が最後に現れない位置を見つける
(public member function) [編集]
文字が最初に現れない位置を見つける
(std::basic_string<CharT,Traits,Allocator> の public メンバ関数) [編集]
English 日本語 中文(简体) 中文(繁體)