std::basic_string_view<CharT,Traits>::find_first_not_of
ja.cppreference.net より
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) このビュー内で、位置
v から開始して、pos の文字のいずれとも等しくない最初の文字を検索します。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)); // ^ }
関連項目
|
ビュー内の文字を検索
(公開メンバ関数) |
|
|
部分文字列の最後の出現を検索
(公開メンバ関数) |
|
|
文字の最初の出現を検索
(公開メンバ関数) |
|
|
文字の最後の出現を検索
(公開メンバ関数) |
|
|
文字の最後の不在を検索
(公開メンバ関数) |
|
|
文字の最初の不在を検索
( std::basic_string<CharT,Traits,Allocator>の公開メンバ関数)
|