---
name: "std::basic_string_view"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/std::basic_string_view/3cxx"
---

# std::basic\_string\_view(3cxx)

A non-owning reference to a string.

## NAME

std::basic\_string\_view\< \_CharT, \_Traits \> - A non-owning reference to a string.

## SYNOPSIS

`#include <>>`

### Public Types

**using** **const\_iterator** = const value\_type \*\
 **using** **const\_pointer** = const value\_type \*\
 **using** **const\_reference** = const value\_type &\
 **using** **const\_reverse\_iterator** = **std::reverse\_iterator**\< const\_iterator \>\
 **using** **difference\_type** = ptrdiff\_t\
 **using** **iterator** = const\_iterator\
 **using** **pointer** = value\_type \*\
 **using** **reference** = value\_type &\
 **using** **reverse\_iterator** = **const\_reverse\_iterator**\
 **using** **size\_type** = size\_t\
 **using** **traits\_type** = \_Traits\
 **using** **value\_type** = \_CharT\

### Public Member Functions

template\<contiguous\_iterator \_It, sized\_sentinel\_for\< \_It \> \_End\> \
 requires same\_as\<iter\_value\_t\<\_It\>, \_CharT\> && (!convertible\_to\<\_End, size\_type\>)constexpr **basic\_string\_view** (\_It \_\_first, \_End \_\_last) noexcept(noexcept(\_\_last - \_\_first))"\
 constexpr **basic\_string\_view** (const \_CharT \***\_\_str**) noexcept\
 constexpr **basic\_string\_view** (const \_CharT \***\_\_str**, size\_type **\_\_len**) noexcept\
 constexpr **basic\_string\_view** (const **basic\_string\_view** &) noexcept=**default**\
 constexpr const\_reference **at** (size\_type **\_\_pos**) const\
 constexpr const\_reference **back** () const noexcept\
 constexpr const\_iterator **begin** () const noexcept\
 constexpr const\_iterator **cbegin** () const noexcept\
 constexpr const\_iterator **cend** () const noexcept\
 constexpr int **compare** (**basic\_string\_view** **\_\_str**) const noexcept\
 constexpr int **compare** (const \_CharT \***\_\_str**) const noexcept\
 constexpr int **compare** (size\_type **\_\_pos1**, size\_type **\_\_n1**, **basic\_string\_view** **\_\_str**) const\
 constexpr int **compare** (size\_type **\_\_pos1**, size\_type **\_\_n1**, **basic\_string\_view** **\_\_str**, size\_type **\_\_pos2**, size\_type **\_\_n2**) const\
 constexpr int **compare** (size\_type **\_\_pos1**, size\_type **\_\_n1**, const \_CharT \***\_\_str**) const\
 constexpr int **compare** (size\_type **\_\_pos1**, size\_type **\_\_n1**, const \_CharT \***\_\_str**, size\_type **\_\_n2**) const noexcept(**false**)\
 constexpr size\_type **copy** (\_CharT \***\_\_str**, size\_type \_\_n, size\_type **\_\_pos**=0) const\
 constexpr **const\_reverse\_iterator** **crbegin** () const noexcept\
 constexpr **const\_reverse\_iterator** **crend** () const noexcept\
 constexpr const\_pointer **data** () const noexcept\
 constexpr bool **empty** () const noexcept\
 constexpr const\_iterator **end** () const noexcept\
 constexpr bool **ends\_with** (\_CharT \_\_x) const noexcept\
 constexpr bool **ends\_with** (**basic\_string\_view** \_\_x) const noexcept\
 constexpr bool **ends\_with** (const \_CharT \*\_\_x) const noexcept\
 constexpr size\_type **find** (\_CharT \_\_c, size\_type **\_\_pos**=0) const noexcept\
 constexpr size\_type **find** (**basic\_string\_view** **\_\_str**, size\_type **\_\_pos**=0) const noexcept\
 constexpr size\_type **find** (const \_CharT \***\_\_str**, size\_type **\_\_pos**, size\_type \_\_n) const noexcept\
 constexpr size\_type **find** (const \_CharT \***\_\_str**, size\_type **\_\_pos**=0) const noexcept\
 constexpr size\_type **find\_first\_not\_of** (\_CharT \_\_c, size\_type **\_\_pos**=0) const noexcept\
 constexpr size\_type **find\_first\_not\_of** (**basic\_string\_view** **\_\_str**, size\_type **\_\_pos**=0) const noexcept\
 constexpr size\_type **find\_first\_not\_of** (const \_CharT \***\_\_str**, size\_type **\_\_pos**, size\_type \_\_n) const noexcept\
 constexpr size\_type **find\_first\_not\_of** (const \_CharT \***\_\_str**, size\_type **\_\_pos**=0) const noexcept\
 constexpr size\_type **find\_first\_of** (\_CharT \_\_c, size\_type **\_\_pos**=0) const noexcept\
 constexpr size\_type **find\_first\_of** (**basic\_string\_view** **\_\_str**, size\_type **\_\_pos**=0) const noexcept\
 constexpr size\_type **find\_first\_of** (const \_CharT \***\_\_str**, size\_type **\_\_pos**, size\_type \_\_n) const noexcept\
 constexpr size\_type **find\_first\_of** (const \_CharT \***\_\_str**, size\_type **\_\_pos**=0) const noexcept\
 constexpr size\_type **find\_last\_not\_of** (\_CharT \_\_c, size\_type **\_\_pos**=npos) const noexcept\
 constexpr size\_type **find\_last\_not\_of** (**basic\_string\_view** **\_\_str**, size\_type **\_\_pos**=npos) const noexcept\
 constexpr size\_type **find\_last\_not\_of** (const \_CharT \***\_\_str**, size\_type **\_\_pos**, size\_type \_\_n) const noexcept\
 constexpr size\_type **find\_last\_not\_of** (const \_CharT \***\_\_str**, size\_type **\_\_pos**=npos) const noexcept\
 constexpr size\_type **find\_last\_of** (\_CharT \_\_c, size\_type **\_\_pos**=npos) const noexcept\
 constexpr size\_type **find\_last\_of** (**basic\_string\_view** **\_\_str**, size\_type **\_\_pos**=npos) const noexcept\
 constexpr size\_type **find\_last\_of** (const \_CharT \***\_\_str**, size\_type **\_\_pos**, size\_type \_\_n) const noexcept\
 constexpr size\_type **find\_last\_of** (const \_CharT \***\_\_str**, size\_type **\_\_pos**=npos) const noexcept\
 constexpr const\_reference **front** () const noexcept\
 constexpr size\_type **length** () const noexcept\
 constexpr size\_type **max\_size** () const noexcept\
 constexpr **basic\_string\_view** & **operator=** (const **basic\_string\_view** &) noexcept=**default**\
 constexpr const\_reference **operator\[\]** (size\_type **\_\_pos**) const noexcept\
 constexpr **const\_reverse\_iterator** **rbegin** () const noexcept\
 constexpr **void** **remove\_prefix** (size\_type \_\_n) noexcept\
 constexpr **void** **remove\_suffix** (size\_type \_\_n) noexcept\
 constexpr **const\_reverse\_iterator** **rend** () const noexcept\
 constexpr size\_type **rfind** (\_CharT \_\_c, size\_type **\_\_pos**=npos) const noexcept\
 constexpr size\_type **rfind** (**basic\_string\_view** **\_\_str**, size\_type **\_\_pos**=npos) const noexcept\
 constexpr size\_type **rfind** (const \_CharT \***\_\_str**, size\_type **\_\_pos**, size\_type \_\_n) const noexcept\
 constexpr size\_type **rfind** (const \_CharT \***\_\_str**, size\_type **\_\_pos**=npos) const noexcept\
 constexpr size\_type **size** () const noexcept\
 constexpr bool **starts\_with** (\_CharT \_\_x) const noexcept\
 constexpr bool **starts\_with** (**basic\_string\_view** \_\_x) const noexcept\
 constexpr bool **starts\_with** (const \_CharT \*\_\_x) const noexcept\
 constexpr **basic\_string\_view** **substr** (size\_type **\_\_pos**=0, size\_type \_\_n=npos) const noexcept(**false**)\
 constexpr **void** **swap** (**basic\_string\_view** &**\_\_sv**) noexcept\

### Static Public Attributes

**static** constexpr size\_type **npos**\

## Detailed Description

### template\<typename \_CharT, typename \_Traits = std::char\_traits\<\_CharT\>\>

class std::basic\_string\_view\< \_CharT, \_Traits \>"A non-owning reference to a string.

**Template Parameters**

*\_CharT* Type of character \
 *\_Traits* Traits for character type, defaults to char\_traits\<\_CharT\>.

A basic\_string\_view looks like this:

```
_CharT*    _M_str
size_t     _M_len
```

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
