std::strstreambuf::pcount(3)
NAME π
okay bestie, welcome to std::strstreambuf::pcount from the C++ Standard Libary manual β yes, that's the vibe. This function is literally deprecated in C++98 and removed in C++26, so it's giving legacy icon, but we still gotta know what it does. It returns the number of characters written to the output sequence. π
Synopsis π¦
int pcount() const; (deprecated in C++98)
(removed in C++26)
If the next pointer for the put area (std::streambuf::pptr()) is a null pointer, it returns zero. No cap.
Otherwise, it returns the next pointer in the put area minus the beginning pointer in the put area, that is pptr() - pbase(). Math but make it couture. β¨
Parameters πΈ
(none) β that's it, bestie. No params, no drama. π«Ά
Return value π
The number of characters written to the put area. Periodt. π
Example π
#include <iostream>
#include <strstream>
int main()
{
std::strstream dyn; // dynamically-allocated output buffer
dyn << "Test: " << 1.23 << std::ends;
std::strstreambuf* buf = dyn.rdbuf();
std::cout << "The size of the output is "
<< buf->pcount() // or just buf.pcount()
<< " and it holds \"" << dyn.str() << "\"\n";
dyn.freeze(false); // after calling .str() on a dynamic strstream
char arr[10];
std::ostrstream user(arr, 10); // user-provided output buffer
buf = user.rdbuf();
user << 1.23; // note: no std::ends
std::cout.write(arr, buf->pcount()); // or just user.pcount()
std::cout << '\n';
std::istrstream lit("1 2 3"); // read-only fixed-size buffer
buf = lit.rdbuf();
// istrstream has no member pcount(), so lit.pcount() won't work
std::cout << "Input-only pcount() = " << buf->pcount() << '\n';
}
Output: β¨
The size of the output is 11 and it holds "Test: 1.23"
1.23
Input-only pcount() = 0
See also π
pcountobtains the number of characters written (public member function ofstd::strstream)pcountobtains the number of characters written (public member function ofstd::ostrstream)
Bye bestie! This cutie came from http://cppreference.com, dated 2024.06.10 β yes, the std::strstreambuf::pcount(3) page, signed off with sparkles. πβ¨π
π¦ 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