std::experi...last_not_of(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… std::experimental::basic_string_view::find_last_not_of

okay bestie, buckle up β€” this one's from the C++ Standard Library section, and the page you're on is std::experi...last_not_of(3) (yes the header truncates it, that's just how it's filed, we don't make the rules). It's a member of std::experimental::basic_string_view, and it's giving "find me the last character that is not in this club" energy. Let's go πŸ¦‹


✨ SYNOPSIS ✨

All four of these are library fundamentals TS β€” like, they're the experimental ones, iykyk πŸ§ͺ

constexpr size_type
find_last_not_of(basic_string_view v, size_type pos = npos) const noexcept;   // (1)

constexpr size_type
find_last_not_of(CharT c, size_type pos = npos) const noexcept;               // (2)

constexpr size_type
find_last_not_of(const CharT* s, size_type pos, size_type count) const;       // (3)

constexpr size_type
find_last_not_of(const CharT* s, size_type pos = npos) const;                 // (4)

quick vibe check: (1) and (2) are noexcept β€” (3) and (4) are not. noted. 🫢


πŸ” WHAT IT DOES πŸ”

Finds the last character not equal to any of the characters in the given character sequence. Basically: "walk backwards till you find someone who isn't on the list, bestie." πŸŽ€

Here's the breakdown, overload by overload:

  1. Finds the last character not equal to any of the characters of v in this view, starting at position pos.
  2. Equivalent to find_last_not_of(basic_string_view(&c, 1), pos).
  3. Equivalent to find_last_not_of(basic_string_view(s, count), pos).
  4. Equivalent to find_last_not_of(basic_string_view(s), pos).

literally a family of four little icons doing the exact same quest with different starting gear πŸ’…


🌸 PARAMETERS 🌸

  • v β€” view to search for
  • pos β€” position at which to start the search
  • count β€” length of the string of characters to compare
  • s β€” pointer to a string of characters to compare
  • ch β€” character to compare

(yeah the parameter list says ch and the synopsis says CharT c β€” that's the manpage being its authentic self, don't come for me 😭)


⭐ RETURN VALUE ⭐

Position of the last character not equal to any of the characters in the given string, or npos if no such character is found.

🚨 translation: if every character is on the list and nobody's an outsider, you get npos. that's the "no thoughts, head empty, not found" result, bestie.

πŸ”₯ COMPLEXITY πŸ”₯

O(size() * v.size()) at worst.

so like… the worst case is doing the whole comparison thing for every position. it's not the speediest icon at the party but she gets there πŸ’€


πŸ‘‘ SEE ALSO πŸ‘‘

  • find β€” find characters in the view (public member function)
  • rfind β€” find the last occurrence of a substring (public member function)
  • find_first_of β€” find first occurrence of characters (public member function)
  • find_last_of β€” find last occurrence of characters (public member function)
  • find_first_not_of β€” find first absence of characters (public member function)

the whole find family is iconic, honestly 🌈


πŸ“Œ Category

  • Noindexed pages
(that's it. that's the category. no note added. we respect the metadata.) πŸ™ˆ

and that's the whole page, bestie β€” every overload, every parameter, every default, nothing skipped, periodt πŸ’–

source/version + date, as promised: this came from http://cppreference.com, dated 2024.06.10. go drink some water and go find your last-not-of character, you absolute main character 🌟

πŸ“¦ where this page comes from