exit(3) says that stdio
streams are flushed and closed. But nothing tells about C++-specific ofstream
objects.
Does the standard guarantee that ofstream
objects are also flushed and closed properly, or do I have to somehow propagate exit condition to main()
and do a return
there to destroy all automatic ofstreams?
std::exit()
destroys objects with static storage duration (thereby flushing such ofstream
objects). It does not destroy objects with automatic storage duration (leaving such ofstream
objects unflushed).
Whether the ofstream
is flushed depends on its storage duration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With