std::basic_...ambuf::pbump(3)

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

πŸ’… std::basic_streambuf::pbump πŸ’…

okay so welcome to the std::basic_...ambuf::pbump(3) page from the C++ Standard Libary manual πŸ’– β€” yes, the header really spells it β€œLibary”, and we are keeping that typo because it's iconic. This is your group chat explainer for pbump, with every detail intact and zero boring-manpage energy, no cap. ✨

🌸 NAME 🌸

std::basic_streambuf::pbump - std::basic_streambuf::pbump. That's the name, bestie. It's literally the same thing twice and it's giving main character. πŸ’…

✨ Synopsis ✨

protected:
void pbump( int count );

It's protected, so it's not for everyone β€” main character energy only. 🫢

So what does it do? It repositions the put pointer (pptr()) by count characters, and count may be positive or negative. No checks are done for moving the pointer outside the put area [pbase(), epptr()) β€” literally no vibe check. πŸ’€

⚠️ If the pointer is advanced and then overflow() is called to flush the put area to the associated character sequence, the effect is that extra count characters with undefined values are output. Undefined values, bestie β€” not cute. 😭

πŸŽ€ Parameters πŸŽ€

  • count β€” number to add to the put pointer. That's the whole job, slay. πŸ’–

πŸ’œ Return value πŸ’œ

  • (none) β€” literally nothing comes back. The synopsis says void, so it's giving β€œno return value” energy. πŸ¦‹

🧚 Notes 🧚

Because this function takes an int, it cannot manipulate buffers larger than std::numeric_limits<int>::max() characters (LWG issue 255). Big-buffer girlies, this is your lowkey sad moment. 😭

πŸ”₯ Example πŸ”₯

// Run this code

        #include <fstream>
        #include <iostream>
        #include <string>

        struct showput_streambuf : std::filebuf
        {
            using std::filebuf::pbump; // expose protected
            std::string showput() const
            {
                return std::string(pbase(), pptr());
            }
        };

        int main()
        {
            showput_streambuf mybuf;
            mybuf.open("test.txt", std::ios_base::out);
            std::ostream str(&mybuf);
            str << "This is a test" << std::flush << "1234";
            std::cout << "The put area contains: " << mybuf.showput() << '\n';
            mybuf.pbump(10);
            std::cout << "after pbump(10), it contains " << mybuf.showput() <<
       '\n';
        }

⭐ Output ⭐

The put area contains: 1234
after pbump(10), it contains 1234 is a test

The output is exactly this, bestie β€” don't @ me. πŸ’€

πŸ‘€ See also πŸ‘€

  • gbump β€” advances the next pointer in the input sequence (protected member function). It's the input-side sibling, iykyk, periodt. πŸ‘‘

That's the whole page, bestie! Source/version vibe: http://cppreference.com; date: 2024.06.10; footer title: std::basic_...ambuf::pbump(3). Mwah πŸ’‹βœ¨ fr fr.

πŸ“¦ where this page comes from