STD::EXPERIMENTAL::BASIC_STRING_VIEW(3)

πŸ’– std::experimental::basic_string_view< _CharT, _Traits > πŸ’–

okay bestie, welcome to the Library Functions Manual section three, and lemme tell you about the absolute icon that is std::experimental::basic_string_view< _CharT, _Traits >. no cap, she's THAT girl. πŸŽ€


✨ NAME ✨

std::experimental::basic_string_view< _CharT, _Traits > β€” a non-owning reference to a string. that's it, that's the whole vibe. she looks at strings, she does not own them, she does not take responsibility for their lives. main character energy but make it borrowed. πŸ’…


🌸 SYNOPSIS 🌸

#include <>>
ngl that include line is looking a little mysterious today but I'm telling you exactly what the page says, fr fr. 🫢

🌈 Public Types

here's her whole closet of type aliases, and yes she has range:

  • const_iterator
  • const_pointer
  • const_reference
  • const_reverse_iterator
  • difference_type
  • iterator
  • pointer
  • reference
  • reverse_iterator
  • size_type
  • traits_type
  • value_type

πŸ’« Public Member Functions

sit down, hydrate, this list is LONG and she ate every single time:

  • constexpr basic_string_view (const _CharT *__str)
  • constexpr basic_string_view (const _CharT *__str, size_type __len)
  • template<typename _Allocator> basic_string_view (const basic_string< _CharT, _Traits, _Allocator > &__str) noexcept
  • constexpr basic_string_view (const basic_string_view &) noexcept=default
  • constexpr const _CharT & at (size_type __pos) const
  • constexpr const _CharT & back () const
  • 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
  • size_type copy (_CharT *__str, size_type __n, size_type __pos=0) const
  • const_reverse_iterator crbegin () const noexcept
  • const_reverse_iterator crend () const noexcept
  • constexpr const _CharT * data () const noexcept
  • constexpr bool empty () const noexcept
  • constexpr const_iterator end () 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
  • 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
  • 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
  • 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
  • constexpr size_type find_last_of (const _CharT *__str, size_type __pos=npos) const noexcept
  • constexpr const _CharT & front () const
  • constexpr size_type length () const noexcept
  • constexpr size_type max_size () const noexcept
  • template<typename _Allocator> operator basic_string< _CharT, _Traits, _Allocator > () const
  • basic_string_view & operator= (const basic_string_view &) noexcept=default
  • constexpr const _CharT & operator[] (size_type __pos) const
  • const_reverse_iterator rbegin () const noexcept
  • constexpr void remove_prefix (size_type __n)
  • constexpr void remove_suffix (size_type __n)
  • 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 basic_string_view substr (size_type __pos=0, size_type __n=npos) const
  • constexpr void swap (basic_string_view &__sv) noexcept
  • template<typename _Allocator = std::allocator<_CharT>> basic_string< _CharT, _Traits, _Allocator > to_string (const _Allocator &__alloc=_Allocator()) const

like??? the range??? the versatility??? she does find, she does rfind, she does find_first_of, she does find_last_not_of, she does it ALL. πŸ‘‘

⭐ Static Public Attributes

one (1) static attribute, and she's iconic for it:

  • static constexpr size_type npos

πŸ¦‹ Detailed Description πŸ¦‹

template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
class std::experimental::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>. slay, she comes with a default. 🫢

a basic_string_view looks like this, and honestly? the way that it's just two little fields is SO satisfying:

_CharT*    _M_str
size_t     _M_len

that's the whole struct bestie. a pointer and a length. no heap allocation, no drama, no mess. she's literally just ✨pointing✨ at somebody else's string and saying "yeah I know her." the audacity, the elegance, the non-owning of it all. 🌈


πŸ’€ Author πŸ’€

generated automatically by Doxygen for libstdc++ from the source code. not me getting emotionally attached to a machine-generated doc but here we are. 😭


and that's the page!! πŸ’– remember: this whole thing lives in the Library Functions Manual, it's the libstdc++ std::exper..., _Traits >(3) page, and yes the title is genuinely abbreviated like that, we love a mysterious queen. go forth and view strings without owning them, bestie. πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from
  • arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms