std::setfill(3)
π std::setfill(3) β C++ Standard Library π
okay so this is the manual page for std::setfill, and yes the NAME is literally std::setfill β std::setfill. iconic, no notes. π
π NAME π
std::setfill β std::setfill
β¨ Synopsis β¨
Defined in header <iomanip>:
template< class CharT >
/*unspecified*/ setfill( CharT c );
When itβs used in an expression like out << setfill(c), it sets the fill character of the stream out to c. slay β¨
πΈ Parameters πΈ
cβ new value for the fill character. thatβs the whole parameter, bestie π«Ά
π« Return value π«
An object of unspecified type such that:
- if
outis an object of typestd::basic_ostream<CharT, Traits>, the expressionout << setfill(c)- has type
std::basic_ostream<CharT, Traits>& - has value
out - behaves as if it called
f(out, c)
- has type
where the function f is defined as:
template<class CharT, class Traits>
void f(std::basic_ios<CharT, Traits>& str, CharT c)
{
// set fill character
str.fill(c);
}
lowkey important: the return type is unspecified, so donβt go trying to name it, okay? iykyk π
π¦ Notes π¦
The current fill character may be obtained with std::ostream::fill. tiny but useful π
π Example π
Run this code, bestie:
#include <iomanip>
#include <iostream>
int main()
{
std::cout << "default fill: [" << std::setw(10) << 42 << "]\n"
<< "setfill('*'): [" << std::setfill('*')
<< std::setw(10) << 42 << "]\n";
}
β Output β
default fill: [ 42]
setfill('*'): [********42]
π©Ή Defect reports π©Ή
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
- DR:
LWG 183 - Applied to:
C++98 - Behavior as published:
setbasecould only be used with streams of typestd::ostream - Correct behavior: usable with any output character stream
look at that glow-up β¨
π See also π
fillβ manages the fill character (public member function ofstd::basic_ios<CharT,Traits>)internalβ sets the placement of fill charactersleftβ (function)rightβ (function)setwβ changes the width of the next input/output field (function)
okay thatβs the whole page, bestie π
β the footer energy is from http://cppreference.com, version 2024.06.10, and this is the std::setfill(3) page. mwah π«Άπ
π¦ 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