std::ctype:...:do_scan_is(3)

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

✨ std::ctype::scan_is / std::ctype::do_scan_is ✨

okay bestie, welcome to the std::ctype:...:do_scan_is(3) page from the C++ Standard Libary manual. yes, that's the manual name, and yes, we're doing this with full group-chat energy. πŸ’…


🌸 NAME 🌸

std::ctype::scan_is,std::ctype::do_scan_is β€” std::ctype::scan_is,std::ctype::do_scan_is. iconic matched set, no cap. 🫢


✨ Synopsis ✨

Defined in header <locale> β€” literally right there in the header, bestie.

Defined in header <locale>

public:
(1)
const CharT* scan_is( mask m, const CharT* beg, const CharT* end ) const;

protected:
virtual const CharT* do_scan_is( mask m, const CharT* beg, const CharT* end ) const;   (2)
  1. Public member function, calls the protected virtual member function do_scan_is of the most derived class. main character energy: it delegates. πŸ‘‘
  2. Locates the first character in the character array [beg, end) that satisfies the classification mask m, that is, the first character c such that is(m, c) would return true. periodt. πŸ”₯

πŸŽ€ Parameters πŸŽ€

  • m β€” mask to search for. πŸ”Ž
  • beg β€” pointer to the first character in an array of characters to search. 🧚
  • end β€” one past the end pointer for the array of characters to search. πŸŽ€

πŸ’– Return value πŸ’–

Pointer to the first character in [beg, end) that satisfies the mask, or end if no such character was found. that's it, that's the vibe check. ✨


🧚 Example 🧚

okay so run this code, bestie β€” it's giving "skip until the first letter" twice and honestly? obsessed. πŸ’–

// Run this code

#include <clocale>
#include <iostream>
#include <iterator>
#include <locale>

int main()
{
    std::setlocale(LC_ALL, "en_US.utf8");
    std::wcout.imbue(std::locale("en_US.utf8"));
    auto& f = std::use_facet<std::ctype<wchar_t>>(std::wcout.getloc());

    // skip until the first letter
    wchar_t s1[] = L"      \t\t\n  Кошка";
    const wchar_t* p1 = f.scan_is(std::ctype_base::alpha,
       std::begin(s1), std::end(s1));
    std::wcout << '\'' << p1 << "'\n";

    // skip until the first letter
    wchar_t s2[] = L"123456789ネプネプ";
    const wchar_t* p2 = f.scan_is(std::ctype_base::alpha,
       std::begin(s2), std::end(s2));
    std::wcout << '\'' << p2 << "'\n";
}

πŸ–¨οΈ Output: πŸ–¨οΈ

'Кошка'
'ネプネプ'

slay. look at those letters getting found. πŸ’…


πŸ§ͺ Defect reports πŸ§ͺ

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

  • DR: LWG 152 β€” Applied to: C++98 β€” Behavior as published: the effect of do_scan_is mentioned is(m), but is does not have such an overload β€” Correct behavior: corrected to is(m, c). not me reading this twice to make sure every word stayed. 😭

πŸ‘€ See also πŸ‘€

  • scan_is β€” locates the first character in a sequence that conforms to given classification, using the classification table (public member function of std::ctype<char>). πŸ’–
  • do_scan_not [virtual] β€” locates the first character in a sequence that fails given classification (virtual protected member function). πŸ¦‹

mwah πŸ’‹ and that's the whole page β€” source/version: http://cppreference.com, version/date: 2024.06.10, for std::ctype:...:do_scan_is(3). iykyk. 🌈

πŸ“¦ where this page comes from