The key difference between sync
, strict_sync
, and flush
is their return values. All 3 of them . All of them call the flush method on any Filter or Device that's part of the filtering_stream
that satisfies the Flushable concept. Any Filter/Device that does not support the Flushable concept is simply skipped.
sync
returns true unless one of the Flushable Filters/Devices returns false. This means that if there are non-Flushable Filters/Devices that are part of the filtering_stream
, data could get stuck in them, but sync
would return true, since they are not Flushable.
strict_sync
is similar, except if it encounters a non-Flushable Filter/Device. In this case, strict_sync
will return false, even though all of the Flushable Filters/Devices might return true. The reason for this is so that a caller of strict_sync
knows that if it returns true, all of the data was successfully flushed.
The member flush
simply returns a reference to the stream,effectively discarding whether or not the flush was successful. The non-member flush
has it's own rules for what it returns depending on the input value
In your case, the CountableOstreamFilter
is not Flushable (it's not convertible to the necessary flushable_tag). Hence, calls to sync
will return true as long as the flush on the underlying stream is successful. However, strict_sync
should return false.