在线文档教程
C++
字符串 | Strings

std::basic_string_view::find

性病:基本[医]弦[医]意见::查找

constexpr size_type find(basic_string_view v, size_type pos = 0) const;(1)(since C++17)
constexpr size_type find(CharT c, size_type pos = 0) const;(2)(since C++17)
constexpr size_type find(const CharT* s, size_type pos, size_type count) const;(3)(since C++17)
constexpr size_type find(const CharT* s, size_type pos = 0) const;(4)(since C++17)

查找等于给定字符序列的第一个子字符串。

1%29发现第一次v在这个视图中,从位置开始pos...

2%29相当于find(basic_string_view(&c, 1), pos)...

3%29相当于find(basic_string_view(s, count), pos)...

4%29相当于find(basic_string_view(s), pos)...

参数

v-view to search for
pos-position at which to start the search
count-length of substring to search for
s-pointer to a character string to search for
ch-character to search for

返回值

找到子字符串的第一个字符的位置,或npos如果找不到这样的子字符串。

例外

1-2%29

noexcept规格:

noexcept

复杂性

O%28size()%2Av.size()%29最坏。

另见

rfindfind the last occurrence of a substring (public member function)
find_first_offind first occurrence of characters (public member function)
find_last_offind last occurrence of characters (public member function)
find_first_not_offind first absence of characters (public member function)
find_last_not_offind last absence of characters (public member function)

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/string/basic[医]弦[医]查看/查找