跳到主要内容

std::string_view find_first_not_of() 方法

// (1) Const version only
constexpr size_type find_first_not_of( const basic_string& str, size_type pos = 0 ) const noexcept;

// (2) Const version only
constexpr size_type find_first_not_of( const CharT* s, size_type pos, size_type count ) const;

// (3) Const version only
constexpr size_type find_first_not_of( const CharT* s, size_type pos = 0 ) const;

// (4) Const version only
constexpr size_type find_first_not_of( CharT ch, size_type pos = 0 ) const noexcept;

查找不等于给定字符序列中任何字符的第一个字符。

  • (1) 在此视图中,从位置 pos 开始,查找不等于 v 中任何字符的第一个字符。
  • (2) 等同于 find_first_not_of(basic_string_view(std::addressof(c), 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 - 指向要搜索的字符字符串的指针
  • c - 要搜索的字符

返回值

不等于给定字符串中任何字符的第一个字符的位置,如果未找到此类子字符串,则为 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));
// ^
}
本文源自 此 CppReference 页面。它可能为了改进或编辑者偏好而进行了修改。点击“编辑此页面”查看本文档所做的所有更改。
悬停查看原始许可证。

std::string_view find_first_not_of() 方法

// (1) Const version only
constexpr size_type find_first_not_of( const basic_string& str, size_type pos = 0 ) const noexcept;

// (2) Const version only
constexpr size_type find_first_not_of( const CharT* s, size_type pos, size_type count ) const;

// (3) Const version only
constexpr size_type find_first_not_of( const CharT* s, size_type pos = 0 ) const;

// (4) Const version only
constexpr size_type find_first_not_of( CharT ch, size_type pos = 0 ) const noexcept;

查找不等于给定字符序列中任何字符的第一个字符。

  • (1) 在此视图中,从位置 pos 开始,查找不等于 v 中任何字符的第一个字符。
  • (2) 等同于 find_first_not_of(basic_string_view(std::addressof(c), 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 - 指向要搜索的字符字符串的指针
  • c - 要搜索的字符

返回值

不等于给定字符串中任何字符的第一个字符的位置,如果未找到此类子字符串,则为 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));
// ^
}
本文源自 此 CppReference 页面。它可能为了改进或编辑者偏好而进行了修改。点击“编辑此页面”查看本文档所做的所有更改。
悬停查看原始许可证。