std::basic_...nit_buf_ptrs(3)
β¨ NAME β¨
Okay bestie, welcome to the std::basic_...nit_buf_ptrs(3) page β that's the C++ Standard Library manual, and the main character is std::basic_stringbuf::init_buf_ptrs. π«Ά
π SYNOPSIS π
void init_buf_ptrs(); (exposition only*)
This little function initializes the input and output sequences from buf, following whatever mode says. Both buf and mode are exposition-only data members of *this β so they're part of the explanation, not regular public members you can just poke at. π
Immediately after this function returns:
- If
std::ios_base::outis set inmode,pbase()points tobuf.front()andepptr() >= pbase() + buf.size()is true.- In addition, if
std::ios_base::ateis set inmode,pptr() == pbase() + buf.size()is true. - Otherwise,
pptr() == pbase()is true.
- In addition, if
- If
std::ios_base::inis set inmode,eback()points tobuf.front(), andgptr() == eback() && egptr() == eback() + buf.size()is true.
π NOTES π
Okay so efficiency, bestie: stream buffer operations can violate invariants of buf while it's held encapsulated in the std::basic_stringbuf. Example? Writing to characters in the range [buf.data() + buf.size(), buf.data() + buf.capacity()). It's giving "we bend the rules for speed." π
But all operations retrieving a std::basic_string from buf ensure that the std::basic_string invariants hold on the returned value. So the returned string stays valid and iconic. β¨
π©Ή Defect reports π©Ή
The following behavior-changing defect reports were applied retroactively to previously published C++ standards. History said what it said, but the fix is the fix. π©Ή
- DR:
LWG 1448 - Applied to: C++98
- Behavior as published: calling
init_buf_ptrs()madepptr() == pbase() + buf.data()for streams that are both input and output streams - Correct behavior: makes
pptr() == pbase() + buf.size()for append streams
Alright bestie, that's the whole vibe. π¦ This gem came from cppreference.com, dated 2024.06.10, and the page is std::basic_...nit_buf_ptrs(3) β slay, 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