Files
2025-10-25 03:02:53 +03:00

2.5 KiB

[ios.members.static]

31 Input/output library [input.output]

31.5 Iostreams base classes [iostreams.base]

31.5.2 Class ios_base [ios.base]

31.5.2.5 Static members [ios.members.static]

🔗

static bool sync_with_stdio(bool sync = true);

1

#

Effects: If any input or output operation has occurred using the standard streams prior to the call, the effect isimplementation-defined.

Otherwise, called with a false argument, it allows the standard streams to operate independently of the standard C streams.

2

#

Returns: true if the previous state of the standard iostream objects was synchronized and otherwise returnsfalse.

The first time it is called, the function returnstrue.

3

#

Remarks: When a standard iostream object str issynchronized with a standard stdio stream f, the effect of inserting a character c byfputc(f, c); is the same as the effect ofstr.rdbuf()->sputc(c); for any sequences of characters; the effect of extracting a character c byc = fgetc(f); is the same as the effect ofc = str.rdbuf()->sbumpc(); for any sequences of characters; and the effect of pushing back a character c byungetc(c, f); is the same as the effect ofstr.rdbuf()->sputbackc(c); for any sequence of characters.259

259)259)

This implies that operations on a standard iostream object can be mixed arbitrarily with operations on the corresponding stdio stream.

In practical terms, synchronization usually means that a standard iostream object and a standard stdio object share a buffer.