##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::basic_filebuf::sync

From cppreference.com
< cpp‎ | io‎ | basic filebuf

protected: virtual int sync() |  |

If a put area exists (e.g. the file was opened for writing), 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. Typical implementation may empty out the get area and move the current file position back by the corresponding number of bytes.

### [edit] Parameters

(none)

### [edit] Return value

​0​ in case of success, -1 in case of failure.

### [edit] Notes

`sync()` or its equivalent is implicitly called by close(), seekoff(), and seekpos() and explicitly called by std::basic_streambuf::pubsync()

### [edit] Example

| This section is incomplete Reason: no example

### [edit] See also

pubsync | invokes sync() (public member function of `std::basic_streambuf`) [edit]
fflush | synchronizes an output stream with the actual file (function) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_filebuf/sync&oldid=81571"
Category:

- Todo no example