std::strstream::pcount(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 NAME 🌸

std::strstream::pcount - std::strstream::pcount

okay so this page is all about std::strstream::pcount, straight out of the C++ Standard Libary manual (that's the manual name, keeping it exactly as it appears bestie πŸ’…). She's the member function that tells you how many characters got written into the put area. Periodt. ✨

πŸ¦‹ Synopsis πŸ¦‹

int pcount() const;  (deprecated in C++98)
                     (removed in C++26)
🚨 okay bestie, important vibe check: pcount() is deprecated in C++98 and removed in C++26. So she's iconic but very much legacy-coded. 😭

Returns the number of characters that were output in the put area of the associated std::strstreambuf. Effectively calls rdbuf()->pcount().

πŸŽ€ Parameters πŸŽ€

(none) β€” literally no parameters, bestie. She takes nothing. πŸ’…

πŸ”₯ Return value πŸ”₯

The number of characters in the put area, or zero if nothing was output. So yes, if you wrote stuff you get the count, and if you wrote nothing it's a big fat zero. 🫢

✨ Example ✨

// Run this code

#include <iostream>
#include <strstream>

int main()
{
    std::strstream 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::strstream 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: pcount the number of characters written (public member function of std::strstreambuf).

mwah πŸ’‹ this little page came from http://cppreference.com, dated 2024.06.10, and it's std::strstream::pcount(3) β€” bye bestie, go count those chars! πŸ«ΆπŸ’–

πŸ“¦ where this page comes from