std::ctype:...:do_scan_is(3)
β¨ 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)
- Public member function, calls the protected virtual member function
do_scan_isof the most derived class. main character energy: it delegates. π - Locates the first character in the character array
[beg, end)that satisfies the classification maskm, that is, the first charactercsuch thatis(m, c)would returntrue. 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 ofdo_scan_ismentionedis(m), butisdoes not have such an overload β Correct behavior: corrected tois(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 ofstd::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
- 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