std::ends(3)
π NAME π
okay so this is the <pink>std::ends(3)</pink> page from the C++ Standard Libary β manual name folded in right at the top, no boring header-line copy, we move. π
std::endsβstd::endsβ yes bestie, the NAME is literallystd::ends - std::ends.
β¨ Synopsis β¨
Defined in header <ostream> β¨
template< class CharT, class Traits >
std::basic_ostream<CharT, Traits>& ends( std::basic_ostream<CharT, Traits>& os );
It inserts a null character into the output sequence os as if by calling os.put(CharT()). Literally that. π«Ά
This is an output-only I/O manipulator, and it may be called with an expression such as out << std::ends for any out of type std::basic_ostream. Slay. π
πΈ Notes πΈ
This manipulator is typically used with std::ostrstream, when the associated output buffer needs to be null-terminated to be processed as a C string.
Unlike std::endl, this manipulator does not flush the stream. Important bestie behavior. π
π Parameters π
osβ reference to output stream.
π Return value π
os (reference to the stream after insertion of the null character). Yup, it hands you back the stream. π«Ά
π¦ Example π¦
Run this code, bestie:
// Run this code
#include <cstdio>
#include <strstream>
int main()
{
std::ostrstream oss;
oss << "Sample text: " << 42 << std::ends;
std::printf("%s\n", oss.str());
oss.freeze(false); // enable memory deallocation
}
π Output π
Sample text: 42
π See also π
ostrstreamβ implements character array output operations (deprecated in C++98) (class) (removed in C++26). iconic but also deprecated/removed, iykyk π
xoxo, source: http://cppreference.com, version/date: 2024.06.10, page: std::ends(3) β byeeee π«Άπ
π¦ 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