std::ostrstream::pcount(3)
β¨ NAME β¨
Okay bestie, welcome to the std::ostrstream::pcount(3) page from the C++ Standard Libary manual π«Ά. The name is literally std::ostrstream::pcount β std::ostrstream::pcount (yes, it said it twice, and honestly? iconic π
).
π§ Synopsis π§
Here's the signature, no cap:
int pcount() const; (deprecated in C++98)
(removed in C++26)
β οΈ Important vibe check: this is deprecated in C++98 and removed in C++26. So like... it's giving legacy era, bestie π.
So what does it actually do? It returns the number of characters that were output in the put area of the associated std::strstreambuf πΈ. Effectively calls rdbuf()->pcount().
π Parameters π
None. Literally none. Zero. Nada. No arguments to pass, bestie π«Ά.
π Return value π
The number of characters in the put area, or zero if nothing was output. That's it. That's the whole return-value moment β¨.
π Example π
// Run this code β like, go off π
#include <iostream>
#include <strstream>
int main()
{
std::ostrstream dyn; // dynamically-allocated output buffer
dyn << "Test: " << 1.23 << std::ends;
std::cout << "The size of the output is " << dyn.pcount()
<< " and it holds \"" << dyn.str() << "\"\n";
dyn.freeze(false);
char buf[10];
std::ostrstream user(buf, 10); // user-provided output buffer
user << 1.23; // note: no std::ends
std::cout.write(buf, user.pcount());
std::cout << '\n';
}
π₯οΈ Output π₯οΈ
The size of the output is 11 and it holds "Test: 1.23"
1.23
π See also π
pcountβ returns the next pointer minus the beginning pointer in the output sequence:pcountis the number of characters written (public member function ofstd::strstreambuf). π
And that's the page, bestie π. Source/version: http://cppreference.com, dated 2024.06.10 β cute little footer folded into this sign-off instead of copied as a line π. Bye! π¦
π¦ 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