[string.view.find]

# 27 Strings library [[strings]](./#strings)

## 27.3 String view classes [[string.view]](string.view#find)

### 27.3.3 Class template basic_string_view [[string.view.template]](string.view.template#string.view.find)

#### 27.3.3.9 Searching [string.view.find]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1403)

Member functions in this subclause have complexity O(size() * str.size()) at worst,
although implementations should do better[.](#1.sentence-1)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1407)

Let *F* be one offind,rfind,find_first_of,find_last_of,find_first_not_of,
andfind_last_not_of[.](#2.sentence-1)

- [(2.1)](#2.1)

Each member function of the formconstexpr *return-type* *F*(const charT* s, size_type pos) const; has effects equivalent to: return *F*(basic_string_view(s), pos);

- [(2.2)](#2.2)

Each member function of the formconstexpr *return-type* *F*(const charT* s, size_type pos, size_type n) const; has effects equivalent to: return *F*(basic_string_view(s, n), pos);

- [(2.3)](#2.3)

Each member function of the formconstexpr *return-type* *F*(charT c, size_type pos) const noexcept; has effects equivalent to: return *F*(basic_string_view(addressof(c), 1), pos);

[ð](#lib:find,basic_string_view)

`constexpr size_type find(basic_string_view str, size_type pos = 0) const noexcept;
`

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1445)

Let xpos be the lowest position, if possible, such that the following conditions hold:

- [(3.1)](#3.1)

pos <= xpos

- [(3.2)](#3.2)

xpos + str.size() <= size()

- [(3.3)](#3.3)

traits​::​eq(*data_*[xpos + I], str[I]) for all elements I of the string referenced by str[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1456)

*Effects*: Determines xpos[.](#4.sentence-1)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1460)

*Returns*: xpos if the function can determine such a value for xpos[.](#5.sentence-1)

Otherwise, returns npos[.](#5.sentence-2)

[ð](#lib:rfind,basic_string_view)

`constexpr size_type rfind(basic_string_view str, size_type pos = npos) const noexcept;
`

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1472)

Let xpos be the highest position, if possible, such that the following conditions hold:

- [(6.1)](#6.1)

xpos <= pos

- [(6.2)](#6.2)

xpos + str.size() <= size()

- [(6.3)](#6.3)

traits​::​eq(*data_*[xpos + I], str[I]) for all elements I of the string referenced by str[.](#6.sentence-1)

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1483)

*Effects*: Determines xpos[.](#7.sentence-1)

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1487)

*Returns*: xpos if the function can determine such a value for xpos[.](#8.sentence-1)

Otherwise, returns npos[.](#8.sentence-2)

[ð](#lib:find_first_of,basic_string_view)

`constexpr size_type find_first_of(basic_string_view str, size_type pos = 0) const noexcept;
`

[9](#9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1499)

Let xpos be the lowest position, if possible, such that the following conditions hold:

- [(9.1)](#9.1)

pos <= xpos

- [(9.2)](#9.2)

xpos < size()

- [(9.3)](#9.3)

traits​::​eq(*data_*[xpos], str[I]) for some element I of the string referenced by str[.](#9.sentence-1)

[10](#10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1510)

*Effects*: Determines xpos[.](#10.sentence-1)

[11](#11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1514)

*Returns*: xpos if the function can determine such a value for xpos[.](#11.sentence-1)

Otherwise, returns npos[.](#11.sentence-2)

[ð](#lib:find_last_of,basic_string_view)

`constexpr size_type find_last_of(basic_string_view str, size_type pos = npos) const noexcept;
`

[12](#12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1526)

Let xpos be the highest position, if possible, such that the following conditions hold:

- [(12.1)](#12.1)

xpos <= pos

- [(12.2)](#12.2)

xpos < size()

- [(12.3)](#12.3)

traits​::​eq(*data_*[xpos], str[I]) for some element I of the string referenced by str[.](#12.sentence-1)

[13](#13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1537)

*Effects*: Determines xpos[.](#13.sentence-1)

[14](#14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1541)

*Returns*: xpos if the function can determine such a value for xpos[.](#14.sentence-1)

Otherwise, returns npos[.](#14.sentence-2)

[ð](#lib:find_first_not_of,basic_string_view)

`constexpr size_type find_first_not_of(basic_string_view str, size_type pos = 0) const noexcept;
`

[15](#15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1553)

Let xpos be the lowest position, if possible, such that the following conditions hold:

- [(15.1)](#15.1)

pos <= xpos

- [(15.2)](#15.2)

xpos < size()

- [(15.3)](#15.3)

traits​::​eq(*data_*[xpos], str[I]) for no element I of the string referenced by str[.](#15.sentence-1)

[16](#16)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1564)

*Effects*: Determines xpos[.](#16.sentence-1)

[17](#17)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1568)

*Returns*: xpos if the function can determine such a value for xpos[.](#17.sentence-1)

Otherwise, returns npos[.](#17.sentence-2)

[ð](#lib:find_last_not_of,basic_string_view)

`constexpr size_type find_last_not_of(basic_string_view str, size_type pos = npos) const noexcept;
`

[18](#18)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1579)

Let xpos be the highest position, if possible, such that the following conditions hold:

- [(18.1)](#18.1)

xpos <= pos

- [(18.2)](#18.2)

xpos < size()

- [(18.3)](#18.3)

traits​::​eq(*data_*[xpos], str[I]) for no element I of the string referenced by str[.](#18.sentence-1)

[19](#19)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1590)

*Effects*: Determines xpos[.](#19.sentence-1)

[20](#20)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1594)

*Returns*: xpos if the function can determine such a value for xpos[.](#20.sentence-1)

Otherwise, returns npos[.](#20.sentence-2)
