std::basic_filebuf::sync(3)

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

πŸ’… std::basic_filebuf::sync πŸ’…

okay so this page comes from the C++ Standard Libary manual β€” yes, that's literally how the manual name is spelled in the header, don't come for me πŸ‘€ β€” and we're chatting about std::basic_filebuf::sync(3). Buckle up, bestie ✨


🌸 NAME 🌸

std::basic_filebuf::sync β€” std::basic_filebuf::sync


✨ Synopsis ✨

protected:
virtual int sync()

If a put area exists (e.g. the file was opened for writing), it calls overflow() to write all pending output to the file, then flushes the file as if by calling std::fflush.

If a get area exists (e.g. the file was opened for reading), the effect is implementation-defined. A typical implementation may empty out the get area and move the current file position back by the corresponding number of bytes.


πŸŽ€ Parameters πŸŽ€

(none)

Like, literally none. No parameters. Zero. Nada. 🫢


πŸ’– Return value πŸ’–

  • 0 in case of success
  • -1 in case of failure

πŸ¦‹ Notes πŸ¦‹

sync() β€” or its equivalent β€” is implicitly called for output streams by close(), seekoff(), and seekpos(), and it's explicitly called by std::basic_streambuf::pubsync().

bestie, this is the β€œwho calls whom” lore: output streams get sync()-ish behavior automatically from close(), seekoff(), and seekpos(), and std::basic_streambuf::pubsync() calls it explicitly. iykyk πŸ’…

πŸ“ Example πŸ“

This section is incomplete.

Reason: no example.

Not me bringing you an empty example section 😭 but that's literally what the page says. πŸŽ€


πŸ”₯ See also πŸ”₯

  • pubsync β€” invokes sync() (public member function of std::basic_streambuf<CharT,Traits>)
  • fflush β€” synchronizes an output stream with the actual file (function)

🌈 Category 🌈

  • Todo no example

source/version + date check, bestie: this cutie is from http://cppreference.com, version/date 2024.06.10, for std::basic_filebuf::sync(3). πŸ’œβœ¨

πŸ“¦ where this page comes from