Files
cppdraft_translate/cppdraft/iostreams/requirements.md
2025-10-25 03:02:53 +03:00

5.5 KiB
Raw Blame History

[iostreams.requirements]

31 Input/output library [input.output]

31.2 Iostreams requirements [iostreams.requirements]

31.2.1 Imbue limitations [iostream.limits.imbue]

1

#

No function described in [input.output] except forios_base::imbue and basic_filebuf::pubimbue causes any instance ofbasic_ios::imbue orbasic_streambuf::imbue to be called.

If any user function called from a function declared in [input.output] or as an overriding virtual function of any class declared in [input.output] callsimbue, the behavior is undefined.

31.2.2 Types [stream.types]

🔗

using streamoff = implementation-defined;

1

#

The type streamoff is a synonym for one of the signed basic integral types of sufficient size to represent the maximum possible file size for the operating system.255

🔗

using streamsize = implementation-defined;

2

#

The typestreamsize is a synonym for one of the signed basic integral types.

It is used to represent the number of characters transferred in an I/O operation, or the size of I/O buffers.256

255)255)

Typically long long.

256)256)

Most places where streamsize is used would use size_t in C, or ssize_t in POSIX.

31.2.3 Positioning type limitations [iostreams.limits.pos]

1

#

The classes of [input.output] with template argumentscharT andtraits behave as described iftraits::pos_type andtraits::off_type arestreampos andstreamoff respectively.

Except as noted explicitly below, their behavior whentraits::pos_type andtraits::off_type are other types isimplementation-defined.

2

#

[Note 1:

For each of the specializations of char_traits defined in[char.traits.specializations],state_type denotes mbstate_t,pos_type denotes fpos<mbstate_t>, and off_type denotes streamoff.

— end note]

3

#

In the classes of [input.output], a template parameter with namecharT represents a member of the set of types containing char, wchar_t, and any other implementation-defined character container types ([defns.character.container]) that meet the requirements for a character on which any of the iostream components can be instantiated.

31.2.4 Thread safety [iostreams.threadsafety]

1

#

Concurrent access to a stream object ([string.streams], [file.streams]), stream buffer object ([stream.buffers]), or C Library stream ([c.files]) by multiple threads may result in a data race ([intro.multithread]) unless otherwise specified ([iostream.objects]).

[Note 1:

Data races result in undefined behavior ([intro.multithread]).

— end note]

2

#

If one thread makes a library call a that writes a value to a stream and, as a result, another thread reads this value from the stream through a library call b such that this does not result in a data race, thena's write synchronizes withb's read.