[iostreams.requirements] # 31 Input/output library [[input.output]](./#input.output) ## 31.2 Iostreams requirements [iostreams.requirements] ### [31.2.1](#iostream.limits.imbue) Imbue limitations [[iostream.limits.imbue]](iostream.limits.imbue) [1](#iostream.limits.imbue-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L44) No function described in [[input.output]](input.output "31 Input/output library") except forios_base​::​imbue and basic_filebuf​::​pubimbue causes any instance ofbasic_ios​::​imbue orbasic_streambuf​::​imbue to be called[.](#iostream.limits.imbue-1.sentence-1) If any user function called from a function declared in [[input.output]](input.output "31 Input/output library") or as an overriding virtual function of any class declared in [[input.output]](input.output "31 Input/output library") callsimbue, the behavior is undefined[.](#iostream.limits.imbue-1.sentence-2) ### [31.2.2](#stream.types) Types [[stream.types]](stream.types) [🔗](#lib:streamoff) `using streamoff = implementation-defined; ` [1](#stream.types-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L67) 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[.](#stream.types-1.sentence-1)[255](#footnote-255 "Typically long long.") [🔗](#lib:streamsize) `using streamsize = implementation-defined; ` [2](#stream.types-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L81) The typestreamsize is a synonym for one of the signed basic integral types[.](#stream.types-2.sentence-1) It is used to represent the number of characters transferred in an I/O operation, or the size of I/O buffers[.](#stream.types-2.sentence-2)[256](#footnote-256 "Most places where streamsize is used would use size_­t in C, or ssize_­t in POSIX.") [255)](#footnote-255)[255)](#footnoteref-255) Typically long long[.](#footnote-255.sentence-1) [256)](#footnote-256)[256)](#footnoteref-256) Most places where streamsize is used would use size_t in C, or ssize_t in POSIX[.](#footnote-256.sentence-1) ### [31.2.3](#iostreams.limits.pos) Positioning type limitations [[iostreams.limits.pos]](iostreams.limits.pos) [1](#iostreams.limits.pos-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L97) The classes of [[input.output]](input.output "31 Input/output library") with template argumentscharT andtraits behave as described iftraits​::​pos_type andtraits​::​off_type arestreampos andstreamoff respectively[.](#iostreams.limits.pos-1.sentence-1) Except as noted explicitly below, their behavior whentraits​::​pos_type andtraits​::​off_type are other types isimplementation-defined[.](#iostreams.limits.pos-1.sentence-2) [2](#iostreams.limits.pos-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L119) [*Note [1](#iostreams.limits.pos-note-1)*: For each of the specializations of char_traits defined in[[char.traits.specializations]](char.traits.specializations "27.2.4 char_­traits specializations"),state_type denotes mbstate_t,pos_type denotes fpos, and off_type denotes streamoff[.](#iostreams.limits.pos-2.sentence-1) — *end note*] [3](#iostreams.limits.pos-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L128) In the classes of [[input.output]](input.output "31 Input/output library"), 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]](defns.character.container "3.10 character container type")) that meet the requirements for a character on which any of the iostream components can be instantiated[.](#iostreams.limits.pos-3.sentence-1) ### [31.2.4](#iostreams.threadsafety) Thread safety [[iostreams.threadsafety]](iostreams.threadsafety) [1](#iostreams.threadsafety-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L138) Concurrent access to a stream object ([[string.streams]](string.streams "31.8 String-based streams"), [[file.streams]](file.streams "31.10 File-based streams")), stream buffer object ([[stream.buffers]](stream.buffers "31.6 Stream buffers")), or C Library stream ([[c.files]](c.files "31.13 C library files")) by multiple threads may result in a data race ([[intro.multithread]](intro.multithread "6.10.2 Multi-threaded executions and data races")) unless otherwise specified ([[iostream.objects]](iostream.objects "31.4 Standard iostream objects"))[.](#iostreams.threadsafety-1.sentence-1) [*Note [1](#iostreams.threadsafety-note-1)*: Data races result in undefined behavior ([[intro.multithread]](intro.multithread "6.10.2 Multi-threaded executions and data races"))[.](#iostreams.threadsafety-1.sentence-2) — *end note*] [2](#iostreams.threadsafety-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L146) 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, then*a*'s write synchronizes with*b*'s read[.](#iostreams.threadsafety-2.sentence-1)