std::isblank(3)
okay so bestie, welcome to std::isblank(3) π
β yeah, that's the C++ Standard Library section, and this little icon is genuinely obsessed with one (1) question: is this thing a blank character or not? let's get into it π
πΈ NAME πΈ
std::isblank β that's it, that's the name. std::isblank is std::isblank. no notes, slay.
β¨ SYNOPSIS β¨
Defined in header <cctype>:
int isblank( int ch );
(since C++11) π¦
Checks if the given character is a blank character as classified by the currently installed C locale. Blank characters are whitespace characters used to separate words within a sentence. In the default C locale, only space (0x20) and horizontal tab (0x09) are classified as blank characters.
π Heads up, and this is the important part: the behavior is undefined if the value ofchis not representable asunsigned charand is not equal toEOF. Not "kinda weird", not "oopsie" β undefined. respect the vibe check fr fr π
π¦ PARAMETERS π¦
chβ the character to classify. that's the whole gig.
β RETURN VALUE β
Non-zero value if the character is a blank character, zero otherwise. simple as that, iykyk.
π NOTES π
Like all other functions from <cctype>, the behavior of std::isblank is undefined if the argument's value is neither representable as unsigned char nor equal to EOF. So to use these functions safely with plain chars (or signed chars), convert the argument to unsigned char first, bestie π«Ά:
bool my_isblank(char ch)
{
return std::isblank(static_cast<unsigned char>(ch));
}
Similarly, they should not be directly used with standard algorithms when the iterator's value type is char or signed char. Instead, convert the value to unsigned char first:
int count_blanks(const std::string& s)
{
return std::count_if(s.begin(), s.end(),
// static_cast<int(*)(int)>(std::isblank) // wrong
// [](int c){ return std::isblank(c); } // wrong
// [](char c){ return std::isblank(c); } // wrong
[](unsigned char c){ return std::isblank(c); } // correct
);
}
like look at those comments β three wrongs and one correct. the correct one took the unsigned char route and it ATE β¨
π SEE ALSO π
isblank(std::locale)(C++11) β checks if a character is classified as a blank character by a locale (function template) πiswblank(C++11) β checks if a wide character is a blank character (function) πΈ- C documentation for
isblankπ
π ASCII values π
here's the full chart, because of course there's a full chart π§ the flags across the top are: iscntrl, isprint, isspace, isblank, isgraph, ispunct, isalnum, isalpha, isupper, islower, isdigit, isxdigit β and the table's wide-character columns are iswcntrl, iswprint, iswspace, iswblank, iswgraph, iswpunct, iswalnum, iswalpha, iswupper, iswlower, iswdigit, iswxdigit π
decimal hex octal characters iscntrl isprint isspace isblank isgraph ispunct isalnum isalpha isupper islower isdigit isxdigit
0β8 \x0β\x8 \0β\10 control codes (NUL, etc.) β 0 0 0 0 0 0 0 0 0 0 0 0
9 \x9 \11 tab (\t) β 0 0 β 0 β 0 0 0 0 0 0 0 0 0
10β13 \xAβ\xD \12β\15 whitespaces (\n,\v,\f,\r) β 0 0 β 0 0 0 0 0 0 0 0 0 0
14β31 \xEβ\x1F \16β\37 control codes β 0 0 0 0 0 0 0 0 0 0 0 0
32 \x20 \40 space 0 β 0 β 0 β 0 0 0 0 0 0 0 0 0
33β47 \x21β\x2F \41β\57 !"#$%&'()*+,-./ 0 β 0 0 0 β 0 β 0 0 0 0 0 0 0
48β57 \x30β\x39 \60β\71 0123456789 0 β 0 0 0 β 0 0 β 0 0 0 0 β 0 β 0
58β64 \x3Aβ\x40 \72β\100 :;<=>?@ 0 β 0 0 0 β 0 β 0 0 0 0 0 0 0
65β70 \x41β\x46 \101β\106 ABCDEF 0 β 0 0 0 β 0 0 β 0 β 0 β 0 0 0 β 0
71β90 \x47β\x5A \107β\132 GHIJKLMNOPQRSTUVWXYZ 0 β 0 0 0 β 0 0 β 0 β 0 β 0 0 0 0
91β96 \x5Bβ\x60 \133β\140 [\]^_` 0 β 0 0 0 β 0 β 0 0 0 0 0 0 0
97β102 \x61β\x66 \141β\146 abcdef 0 β 0 0 0 β 0 0 β 0 β 0 0 β 0 0 β 0
103β122 \x67β\x7A \147β\172 ghijklmnopqrstuvwxyz 0 β 0 0 0 β 0 0 β 0 β 0 0 β 0 0 0
123β126 \x7Bβ\x7E \172β\176 {|}~ 0 β 0 0 0 β 0 β 0 0 0 0 0 0 0
127 \x7F \177 backspace character (DEL) β 0 0 0 0 0 0 0 0 0 0 0 0
look at that lonely little β 0 in isblank for space and tab. those two are the main characters of this entire manpage ππ
and that's the whole thing bestie!! π«Ά this page came from http://cppreference.com, dated 2024.06.10, and yes β the page is literally called std::isblank(3), which is honestly iconic of it. mwah π go classify some blanks, stay unsigned char, and don't let anyone catch you passing a raw char πβ¨π
π¦ 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