This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

View File

@@ -0,0 +1,93 @@
[iostream.objects.overview]
# 31 Input/output library [[input.output]](./#input.output)
## 31.4 Standard iostream objects [[iostream.objects]](iostream.objects#overview)
### 31.4.2 Overview [iostream.objects.overview]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L468)
In this Clause, the type name FILE refers to
the type FILE declared in [<cstdio>](cstdio.syn#header:%3ccstdio%3e "31.13.1Header <cstdio> synopsis[cstdio.syn]")[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L472)
The header [<iostream>](iostream.syn#header:%3ciostream%3e "31.4.1Header <iostream> synopsis[iostream.syn]") declares objects that associate objects with the
standard C streams provided for by the functions declared in[<cstdio>](cstdio.syn#header:%3ccstdio%3e "31.13.1Header <cstdio> synopsis[cstdio.syn]"), and includes all the headers necessary to use these objects[.](#2.sentence-1)
The dynamic types of the stream buffers
initially associated with these objects are unspecified,
but they have the behavior specified forstd::basic_filebuf<char> orstd::basic_filebuf<wchar_t>[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L484)
The objects are constructed and the associations are established at some
time prior to or during the first time an object of classios_base::Init is constructed, and in any case before the body
of main ([[basic.start.main]](basic.start.main "6.10.3.1main function")) begins execution[.](#3.sentence-1)
The objects are not destroyed during program execution[.](#3.sentence-2)[258](#footnote-258 "Constructors and destructors for objects with static storage duration can access these objects to read input from stdin or write output to stdout or stderr.")
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L501)
*Recommended practice*: If it is possible for them to do so, implementations should
initialize the objects earlier than required[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L506)
The results of including [<iostream>](iostream.syn#header:%3ciostream%3e "31.4.1Header <iostream> synopsis[iostream.syn]") in a translation unit shall be as if[<iostream>](iostream.syn#header:%3ciostream%3e "31.4.1Header <iostream> synopsis[iostream.syn]") defined an instance of ios_base::Init with static
storage duration[.](#5.sentence-1)
Each C++ library module ([[std.modules]](std.modules "16.4.2.4Modules")) in a hosted implementation
shall behave as if it contains an interface unit that
defines an unexported ios_base::Init variable with
ordered initialization ([[basic.start.dynamic]](basic.start.dynamic "6.10.3.3Dynamic initialization of non-block variables"))[.](#5.sentence-2)
[*Note [1](#note-1)*:
As a result, the definition of that variable is appearance-ordered before
any declaration following the point of importation of a C++ library module[.](#5.sentence-3)
Whether such a definition exists is unobservable by a program that
does not reference any of the standard iostream objects[.](#5.sentence-4)
— *end note*]
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L522)
Mixing operations on corresponding wide- and narrow-character streams
follows the same semantics as mixing such operations onFILEs,
as specified in the C standard library[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L528)
Concurrent access to a synchronized ([[ios.members.static]](ios.members.static "31.5.2.5Static members")) standard iostream object's formatted and unformatted input ([[istream]](istream "31.7.5.2Class template basic_­istream")) and output ([[ostream]](ostream "31.7.6.2Class template basic_­ostream")) functions or a standard C stream by multiple threads does not result in a data race ([[intro.multithread]](intro.multithread "6.10.2Multi-threaded executions and data races"))[.](#7.sentence-1)
[*Note [2](#note-2)*:
Unsynchronized concurrent use of these objects and streams by multiple threads
can result in interleaved characters[.](#7.sentence-2)
— *end note*]
See also: ISO/IEC 9899:2024, 7.21.2
[258)](#footnote-258)[258)](#footnoteref-258)
Constructors and destructors for objects with
static storage duration can
access these objects to read input fromstdin or write output tostdout orstderr[.](#footnote-258.sentence-1)