Previous fileTop of DocumentContentsIndex pageNext file
Apache C++ Standard Library User's Guide

37.2 An Example

A program can register a callback function on a particular stream as follows:

//1The function show_event is now called with either std::ios_base::erase_event, std::ios_base::imbue_event, or std::ios_base::copyfmt_event as the first argument, depending on whether the destruction of the stream, the imbuing of a new locale, or a call to std::basic_ios<>::copyfmt() initiated the callback.
//2This causes show_event to be called. The first argument is std::ios_base::imbue_event; the second argument is a reference to the stream where the event occurred, which is s in this case; and the third argument is always the index provided in the call to std::ios_base<>::register_callback(), which is 0 in this case.

If more than one function is registered, functions are called in the opposite order of registration.

Please refer to Section 26.9.2 for an example using callback functions with a user-defined stream inserter.

Previous fileTop of DocumentContentsIndex pageNext file