std::basic_...first_not_of(3)
β¨ NAME β¨
Hey bestie, welcome to the std::basic_...first_not_of(3) page from the C++ Standard Libary β yes, the header spells it βLibary,β and we are keeping the lore exactly as it is π
.
The name is std::basic_string_view::find_first_not_of β and the manpage also repeats it after the dash as std::basic_string_view::find_first_not_of, so both are here, because apparently the name wanted main character energy twice π.
π Synopsis
Okay so the synopsis in the original is line-wrapped like a group chat at 3 a.m., but here are the exact overloads with every token, number, since C++17, const, and noexcept preserved:
constexpr size_type
find_first_not_of( basic_string_view v, size_type pos = 0 )
(1) (since C++17)
const noexcept;
constexpr size_type
find_first_not_of( CharT ch, size_type pos = 0 ) const
(2) (since C++17)
noexcept;
constexpr size_type
find_first_not_of( const CharT* s, size_type pos, size_type
(3) (since C++17)
count ) const;
constexpr size_type
(4) (since C++17)
find_first_not_of( const CharT* s, size_type pos = 0 ) const;
The whole vibe: it finds the first character not equal to any of the characters in the given character sequence. It's giving βspot the odd one outβ π₯.
- Finds the first character not equal to any of the characters of
vin this view, starting at positionpos. - Equivalent to
find_first_not_of(basic_string_view(std::addressof(ch), 1), pos). - Equivalent to
find_first_not_of(basic_string_view(s, count), pos). - Equivalent to
find_first_not_of(basic_string_view(s), pos).
π§Έ Parameters
vβ view to search for. The character crew you're checking against π.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.
π Return value
Position of the first character not equal to any of the characters in the given string, or std::string_view::npos if no such character is found. No match? You get npos, the official βnopeβ value π.
β±οΈ Complexity
O(size() * v.size()) at worst. Nested-loop energy, fr fr π.
π» Example
// Run this code
#include <string_view>
using namespace std::literals;
int main()
{
static_assert(2 == "BCDEF"sv.find_first_not_of("ABC"));
// ^
static_assert(4 == "BCDEF"sv.find_first_not_of("ABC", 4));
// ^
static_assert(1 == "BCDEF"sv.find_first_not_of('B'));
// ^
static_assert(3 == "BCDEF"sv.find_first_not_of('D', 2));
// ^
}
π 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_last_not_ofβ find last absence of characters (public member function)find_first_not_ofβ find first absence of characters (public member function ofstd::basic_string<CharT,Traits,Allocator>)
Cute little sign-off bestie: source/version is http://cppreference.com, dated 2024.06.10, and the manual is std::basic_...first_not_of(3). Go find your first not-of character and slay ππ¦β¨.
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms