tangled
alpha
login
or
join now
stau.space
/
stl-browser
0
fork
atom
C++ Standard Template Library browser.
0
fork
atom
overview
issues
pulls
pipelines
first commit
Sunglas
2 years ago
9da94c69
+1960
10 changed files
expand all
collapse all
unified
split
.clang-format
.clangd
Makefile
basic_ifstream.html
build
a.out
src
indexer.cpp
indexer.hpp
main.cpp
prelude.cpp
prelude.hpp
+10
.clang-format
···
1
1
+
BasedOnStyle: LLVM
2
2
+
IndentWidth: 8
3
3
+
UseTab: Always
4
4
+
AllowShortIfStatementsOnASingleLine: false
5
5
+
IndentCaseLabels: false
6
6
+
PointerAlignment: Left
7
7
+
AllowShortFunctionsOnASingleLine: None
8
8
+
BreakBeforeBraces: Custom
9
9
+
BraceWrapping:
10
10
+
AfterFunction: true
+2
.clangd
···
1
1
+
CompileFlags:
2
2
+
Add: [-std=c++20]
+22
Makefile
···
1
1
+
.POSIX:
2
2
+
3
3
+
CXX=g++
4
4
+
WARNINGS=-Werror -Wall -Wextra
5
5
+
CXXFLAGS=-std=c++2b $(WARNINGS)
6
6
+
SRC=src/*.cpp
7
7
+
HEADERS=src/*.hpp
8
8
+
BUILD=build
9
9
+
10
10
+
build: src/main.cpp
11
11
+
$(CXX) $(SRC) -g -o $(BUILD)/a.out $(CXXFLAGS)
12
12
+
13
13
+
run: build
14
14
+
./$(BUILD)/a.out $(ARGS)
15
15
+
16
16
+
test:
17
17
+
./$(BUILD)/a.out $(ARGS)
18
18
+
19
19
+
format:
20
20
+
clang-format -i $(SRC) $(HEADERS)
21
21
+
22
22
+
.PHONY: build run format
+1426
basic_ifstream.html
···
1
1
+
<!DOCTYPE html>
2
2
+
<html lang="en" dir="ltr" class="client-nojs">
3
3
+
<head>
4
4
+
<title>std::basic_ifstream - cppreference.com</title>
5
5
+
<meta charset="UTF-8" />
6
6
+
<meta name="generator" content="MediaWiki 1.21.2" />
7
7
+
<link rel="alternate" type="application/x-wiki" title="Edit" href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&action=edit" />
8
8
+
<link rel="edit" title="Edit" href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&action=edit" />
9
9
+
<link rel="shortcut icon" href="../../../favicon.ico" />
10
10
+
<link rel="search" type="application/opensearchdescription+xml" href="../../../mwiki/opensearch_desc.php" title="cppreference.com (en)" />
11
11
+
<link rel="EditURI" type="application/rsd+xml" href="https://en.cppreference.com/mwiki/api.php?action=rsd" />
12
12
+
<link rel="alternate" type="application/atom+xml" title="cppreference.com Atom feed" href="https://en.cppreference.com/mwiki/index.php?title=Special:RecentChanges&feed=atom" />
13
13
+
<link rel="stylesheet" href="../../../mwiki/load.php%3Fdebug=false&lang=en&modules=ext.gadget.ColiruCompiler,MathJax|ext.rtlcite|mediawiki.legacy.commonPrint,shared|skins.cppreference2&only=styles&skin=cppreference2&*.css" />
14
14
+
<meta name="ResourceLoaderDynamicStyles" content="" />
15
15
+
<link rel="stylesheet" href="../../../mwiki/load.php%3Fdebug=false&lang=en&modules=site&only=styles&skin=cppreference2&*.css" />
16
16
+
<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}#toc{display:none}.editsection{display:none}
17
17
+
/* cache key: mwiki1-mwiki_en_:resourceloader:filter:minify-css:7:472787eddcf4605d11de8c7ef047234f */</style>
18
18
+
19
19
+
<script src="../../../mwiki/load.php%3Fdebug=false&lang=en&modules=startup&only=scripts&skin=cppreference2&*"></script>
20
20
+
<script>if(window.mw){
21
21
+
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"cpp/io/basic_ifstream","wgTitle":"cpp/io/basic ifstream","wgCurRevisionId":158179,"wgArticleId":494,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":[],"wgBreakFrames":false,"wgPageContentLanguage":"en","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgMonthNamesShort":["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"wgRelevantPageName":"cpp/io/basic_ifstream","wgRestrictionEdit":[],"wgRestrictionMove":[]});
22
22
+
}</script><script>if(window.mw){
23
23
+
mw.loader.implement("user.options",function(){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":0,"showtoolbar":1,"skin":"cppreference2","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
24
24
+
"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"en","language":"en","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"gadget-ColiruCompiler":1,"gadget-MathJax":1});;},{},{});mw.loader.implement("user.tokens",function(){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});;},{},{});
25
25
+
/* cache key: mwiki1-mwiki_en_:resourceloader:filter:minify-js:7:9f05c6caceb9bb1a482b6cebd4c5a330 */
26
26
+
}</script>
27
27
+
<script>if(window.mw){
28
28
+
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
29
29
+
}</script>
30
30
+
<style type="text/css">/*<![CDATA[*/
31
31
+
.source-cpp {line-height: normal;}
32
32
+
.source-cpp li, .source-cpp pre {
33
33
+
line-height: normal; border: 0px none white;
34
34
+
}
35
35
+
/**
36
36
+
* GeSHi Dynamically Generated Stylesheet
37
37
+
* --------------------------------------
38
38
+
* Dynamically generated stylesheet for cpp
39
39
+
* CSS class: source-cpp, CSS id:
40
40
+
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
41
41
+
* (http://qbnz.com/highlighter/ and http://geshi.org/)
42
42
+
* --------------------------------------
43
43
+
*/
44
44
+
.cpp.source-cpp .de1, .cpp.source-cpp .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
45
45
+
.cpp.source-cpp {font-family:monospace;}
46
46
+
.cpp.source-cpp .imp {font-weight: bold; color: red;}
47
47
+
.cpp.source-cpp li, .cpp.source-cpp .li1 {font-weight: normal; vertical-align:top;}
48
48
+
.cpp.source-cpp .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
49
49
+
.cpp.source-cpp .li2 {font-weight: bold; vertical-align:top;}
50
50
+
.cpp.source-cpp .kw1 {color: #0000dd;}
51
51
+
.cpp.source-cpp .kw2 {color: #0000ff;}
52
52
+
.cpp.source-cpp .kw3 {color: #0000dd;}
53
53
+
.cpp.source-cpp .kw4 {color: #0000ff;}
54
54
+
.cpp.source-cpp .co1 {color: #909090;}
55
55
+
.cpp.source-cpp .co2 {color: #339900;}
56
56
+
.cpp.source-cpp .coMULTI {color: #ff0000; font-style: italic;}
57
57
+
.cpp.source-cpp .es0 {color: #008000; font-weight: bold;}
58
58
+
.cpp.source-cpp .es1 {color: #008000; font-weight: bold;}
59
59
+
.cpp.source-cpp .es2 {color: #008000; font-weight: bold;}
60
60
+
.cpp.source-cpp .es3 {color: #008000; font-weight: bold;}
61
61
+
.cpp.source-cpp .es4 {color: #008000; font-weight: bold;}
62
62
+
.cpp.source-cpp .es5 {color: #008000; font-weight: bold;}
63
63
+
.cpp.source-cpp .br0 {color: #008000;}
64
64
+
.cpp.source-cpp .sy0 {color: #008000;}
65
65
+
.cpp.source-cpp .sy1 {color: #000080;}
66
66
+
.cpp.source-cpp .sy2 {color: #000040;}
67
67
+
.cpp.source-cpp .sy3 {color: #000040;}
68
68
+
.cpp.source-cpp .sy4 {color: #008080;}
69
69
+
.cpp.source-cpp .st0 {color: #008000;}
70
70
+
.cpp.source-cpp .nu0 {color: #000080;}
71
71
+
.cpp.source-cpp .nu6 {color: #000080;}
72
72
+
.cpp.source-cpp .nu8 {color: #000080;}
73
73
+
.cpp.source-cpp .nu12 {color: #000080;}
74
74
+
.cpp.source-cpp .nu16 {color:#000080;}
75
75
+
.cpp.source-cpp .nu17 {color:#000080;}
76
76
+
.cpp.source-cpp .nu18 {color:#000080;}
77
77
+
.cpp.source-cpp .nu19 {color:#000080;}
78
78
+
.cpp.source-cpp .ln-xtra, .cpp.source-cpp li.ln-xtra, .cpp.source-cpp div.ln-xtra {background-color: #ffc;}
79
79
+
.cpp.source-cpp span.xtra { display:block; }
80
80
+
81
81
+
/*]]>*/
82
82
+
</style><style type="text/css">/*<![CDATA[*/
83
83
+
.source-text {line-height: normal;}
84
84
+
.source-text li, .source-text pre {
85
85
+
line-height: normal; border: 0px none white;
86
86
+
}
87
87
+
/**
88
88
+
* GeSHi Dynamically Generated Stylesheet
89
89
+
* --------------------------------------
90
90
+
* Dynamically generated stylesheet for text
91
91
+
* CSS class: source-text, CSS id:
92
92
+
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
93
93
+
* (http://qbnz.com/highlighter/ and http://geshi.org/)
94
94
+
* --------------------------------------
95
95
+
*/
96
96
+
.text.source-text .de1, .text.source-text .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
97
97
+
.text.source-text {font-family:monospace;}
98
98
+
.text.source-text .imp {font-weight: bold; color: red;}
99
99
+
.text.source-text li, .text.source-text .li1 {font-weight: normal; vertical-align:top;}
100
100
+
.text.source-text .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
101
101
+
.text.source-text .li2 {font-weight: bold; vertical-align:top;}
102
102
+
.text.source-text .ln-xtra, .text.source-text li.ln-xtra, .text.source-text div.ln-xtra {background-color: #ffc;}
103
103
+
.text.source-text span.xtra { display:block; }
104
104
+
105
105
+
/*]]>*/
106
106
+
</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]--></head>
107
107
+
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_io_basic_ifstream skin-cppreference2 action-view cpp-navbar">
108
108
+
<!-- header -->
109
109
+
<div id="mw-head" class="noprint">
110
110
+
<div id="cpp-head-first-base">
111
111
+
<div id="cpp-head-first">
112
112
+
<h5><a href="../../../index.html">
113
113
+
cppreference.com </a></h5>
114
114
+
<div id="cpp-head-search">
115
115
+
116
116
+
<!-- 0 -->
117
117
+
<div id="p-search">
118
118
+
<form action="https://duckduckgo.com/" method="get">
119
119
+
<input type="hidden" name="sites" value="cppreference.com">
120
120
+
<input type="search" name="q">
121
121
+
<input type="submit" value="Search">
122
122
+
</form>
123
123
+
</div>
124
124
+
125
125
+
<!-- /0 -->
126
126
+
</div>
127
127
+
<div id="cpp-head-personal">
128
128
+
129
129
+
<!-- 0 -->
130
130
+
<div id="p-personal" class="">
131
131
+
<span id="pt-login"><a href="https://en.cppreference.com/mwiki/index.php?title=Special:UserLogin&returnto=cpp%2Fio%2Fbasic+ifstream" title="You are encouraged to log in; however, it is not mandatory [o]" accesskey="o">Log in</a></span></div>
132
132
+
133
133
+
<!-- /0 -->
134
134
+
</div>
135
135
+
136
136
+
</div>
137
137
+
</div>
138
138
+
<div id="cpp-head-second-base">
139
139
+
<div id="cpp-head-second">
140
140
+
<div id="cpp-head-tools-left">
141
141
+
142
142
+
<!-- 0 -->
143
143
+
<div id="p-namespaces" class="vectorTabs">
144
144
+
<h5>Namespaces</h5>
145
145
+
<ul>
146
146
+
<li id="ca-nstab-main" class="selected"><span><a href="basic_ifstream.html" title="View the content page [c]" accesskey="c">Page</a></span></li>
147
147
+
<li id="ca-talk" class="new"><span><a href="https://en.cppreference.com/mwiki/index.php?title=Talk:cpp/io/basic_ifstream&action=edit&redlink=1" title="Discussion about the content page [t]" accesskey="t">Discussion</a></span></li>
148
148
+
</ul>
149
149
+
</div>
150
150
+
151
151
+
<!-- /0 -->
152
152
+
153
153
+
<!-- 1 -->
154
154
+
<div id="p-variants" class="vectorMenu emptyPortlet">
155
155
+
<h5><span>Variants</span><a href="basic_ifstream.html#"></a></h5>
156
156
+
<div class="menu">
157
157
+
<ul>
158
158
+
</ul>
159
159
+
</div>
160
160
+
</div>
161
161
+
162
162
+
<!-- /1 -->
163
163
+
</div>
164
164
+
<div id="cpp-head-tools-right">
165
165
+
166
166
+
<!-- 0 -->
167
167
+
<div id="p-views" class="vectorTabs">
168
168
+
<h5>Views</h5>
169
169
+
<ul>
170
170
+
<li id="ca-view" class="selected"><span><a href="basic_ifstream.html" >View</a></span></li>
171
171
+
<li id="ca-edit"><span><a href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&action=edit" title="You can edit this page. Please use the preview button before saving [e]" accesskey="e">Edit</a></span></li>
172
172
+
<li id="ca-history" class="collapsible"><span><a href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&action=history" title="Past revisions of this page [h]" accesskey="h">History</a></span></li>
173
173
+
</ul>
174
174
+
</div>
175
175
+
176
176
+
<!-- /0 -->
177
177
+
178
178
+
<!-- 1 -->
179
179
+
<div id="p-cactions" class="vectorMenu emptyPortlet">
180
180
+
<h5><span>Actions</span><a href="basic_ifstream.html#"></a></h5>
181
181
+
<div class="menu">
182
182
+
<ul>
183
183
+
</ul>
184
184
+
</div>
185
185
+
</div>
186
186
+
187
187
+
<!-- /1 -->
188
188
+
</div>
189
189
+
</div>
190
190
+
</div>
191
191
+
</div>
192
192
+
<!-- /header -->
193
193
+
<!-- content -->
194
194
+
<style type="text/css">
195
195
+
#carbonads {
196
196
+
display: block;
197
197
+
overflow: hidden;
198
198
+
position: absolute;
199
199
+
text-align: center;
200
200
+
left: -170px;
201
201
+
max-width: 150px;
202
202
+
border-radius: 4px;
203
203
+
border: solid 1px hsla(0, 0%, 0%, .1);
204
204
+
background-color: hsl(0, 0%, 98%);
205
205
+
font-size: 12px;
206
206
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu,
207
207
+
Cantarell, "Helvetica Neue", Helvetica, Arial, sans-serif;
208
208
+
line-height: 1.5;
209
209
+
}
210
210
+
211
211
+
#carbonads a {
212
212
+
color: inherit;
213
213
+
text-decoration: none;
214
214
+
}
215
215
+
216
216
+
#carbonads a:hover {
217
217
+
color: inherit;
218
218
+
}
219
219
+
220
220
+
#carbonads span {
221
221
+
position: relative;
222
222
+
display: block;
223
223
+
overflow: hidden;
224
224
+
}
225
225
+
226
226
+
.carbon-img {
227
227
+
display: block;
228
228
+
margin-bottom: 8px;
229
229
+
max-width: 150px;
230
230
+
line-height: 1;
231
231
+
}
232
232
+
233
233
+
.carbon-img img {
234
234
+
display: block;
235
235
+
margin: 0 auto;
236
236
+
max-width: 150px !important;
237
237
+
width: 150px;
238
238
+
height: auto;
239
239
+
}
240
240
+
241
241
+
.carbon-text {
242
242
+
display: block;
243
243
+
padding: 0 1em 8px;
244
244
+
}
245
245
+
246
246
+
.carbon-poweredby {
247
247
+
display: block;
248
248
+
padding: 8px 12px;
249
249
+
background: repeating-linear-gradient(-45deg, transparent, transparent 5px, hsla(0, 0%, 0%, .025) 5px, hsla(0, 0%, 0%, .025) 10px) hsla(203, 11%, 95%, .4);
250
250
+
text-transform: uppercase;
251
251
+
letter-spacing: .5px;
252
252
+
font-weight: 600;
253
253
+
font-size: 9px;
254
254
+
line-height: 1;
255
255
+
}
256
256
+
html { font-variant-ligatures: no-common-ligatures; }
257
257
+
</style>
258
258
+
<div id="cpp-content-base">
259
259
+
<div id="content">
260
260
+
<a id="top"></a>
261
261
+
<div id="mw-js-message" style="display:none;"></div>
262
262
+
<!-- firstHeading -->
263
263
+
<script async type="text/javascript" src="https://cdn.carbonads.com/carbon.js?serve=CKYITK7M&placement=cppreferencecom" id="_carbonads_js"></script>
264
264
+
<h1 id="firstHeading" class="firstHeading"><span style="font-size:0.7em; line-height:130%">std::</span>basic_ifstream</h1>
265
265
+
<!-- /firstHeading -->
266
266
+
<!-- bodyContent -->
267
267
+
<div id="bodyContent">
268
268
+
<!-- tagline -->
269
269
+
<div id="siteSub">From cppreference.com</div>
270
270
+
<!-- /tagline -->
271
271
+
<!-- subtitle -->
272
272
+
<div id="contentSub"><span class="subpages">< <a href="../../cpp.html" title="cpp">cpp</a>‎ | <a href="../io.html" title="cpp/io">io</a></span></div>
273
273
+
<!-- /subtitle -->
274
274
+
<!-- bodycontent -->
275
275
+
<div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><div class="t-navbar" style=""><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../../cpp.html" title="cpp">C++</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="line-height:1.1em;">
276
276
+
<tr class="t-nv"><td colspan="5"><a href="../compiler_support.html" title="cpp/compiler support">Compiler support</a></td></tr>
277
277
+
<tr class="t-nv"><td colspan="5"><a href="../freestanding.html" title="cpp/freestanding">Freestanding and hosted</a></td></tr>
278
278
+
<tr class="t-nv"><td colspan="5"><a href="../language.html" title="cpp/language">Language</a></td></tr>
279
279
+
<tr class="t-nv"><td colspan="5"><a href="../standard_library.html" title="cpp/standard library">Standard library</a></td></tr>
280
280
+
<tr class="t-nv"><td colspan="5"><a href="../headers.html" title="cpp/header">Standard library headers</a></td></tr>
281
281
+
<tr class="t-nv"><td colspan="5"><a href="../named_req.html" title="cpp/named req">Named requirements</a></td></tr>
282
282
+
<tr class="t-nv"><td colspan="5"><a href="../feature_test.html" title="cpp/feature test">Feature test macros</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span></td></tr>
283
283
+
<tr class="t-nv"><td colspan="5"><a href="../utility.html#Language_support" title="cpp/utility">Language support library</a></td></tr>
284
284
+
<tr class="t-nv"><td colspan="5"><a href="../concepts.html" title="cpp/concepts">Concepts library</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span></td></tr>
285
285
+
<tr class="t-nv"><td colspan="5"><a href="../meta.html" title="cpp/meta">Metaprogramming library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
286
286
+
<tr class="t-nv"><td colspan="5"><a href="../error.html" title="cpp/error">Diagnostics library</a></td></tr>
287
287
+
<tr class="t-nv"><td colspan="5"><a href="../utility.html" title="cpp/utility">General utilities library</a></td></tr>
288
288
+
<tr class="t-nv"><td colspan="5"><a href="../string.html" title="cpp/string">Strings library</a></td></tr>
289
289
+
<tr class="t-nv"><td colspan="5"><a href="../container.html" title="cpp/container">Containers library</a></td></tr>
290
290
+
<tr class="t-nv"><td colspan="5"><a href="../iterator.html" title="cpp/iterator">Iterators library</a></td></tr>
291
291
+
<tr class="t-nv"><td colspan="5"><a href="../ranges.html" title="cpp/ranges">Ranges library</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span></td></tr>
292
292
+
<tr class="t-nv"><td colspan="5"><a href="../algorithm.html" title="cpp/algorithm">Algorithms library</a></td></tr>
293
293
+
<tr class="t-nv"><td colspan="5"><a href="../numeric.html" title="cpp/numeric">Numerics library</a></td></tr>
294
294
+
<tr class="t-nv"><td colspan="5"><a href="../locale.html" title="cpp/locale">Localizations library</a></td></tr>
295
295
+
<tr class="t-nv"><td colspan="5"><a href="../io.html" title="cpp/io">Input/output library</a></td></tr>
296
296
+
<tr class="t-nv"><td colspan="5"><a href="../filesystem.html" title="cpp/filesystem">Filesystem library</a> <span class="t-mark-rev t-since-cxx17">(C++17)</span></td></tr>
297
297
+
<tr class="t-nv"><td colspan="5"><a href="../regex.html" title="cpp/regex">Regular expressions library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
298
298
+
<tr class="t-nv"><td colspan="5"><a href="../thread.html" title="cpp/thread">Concurrency support library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
299
299
+
<tr class="t-nv"><td colspan="5"><a href="../experimental.html" title="cpp/experimental">Technical specifications</a></td></tr>
300
300
+
<tr class="t-nv"><td colspan="5"><a href="../symbol_index.html" title="cpp/symbol index">Symbols index</a></td></tr>
301
301
+
<tr class="t-nv"><td colspan="5"><a href="../links/libs.html" title="cpp/links/libs">External libraries</a></td></tr>
302
302
+
</table></div><div><span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/navbar_content&action=edit">[edit]</a></span></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../io.html" title="cpp/io"> Input/output library</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
303
303
+
<tr class="t-nv"><td colspan="5"> <a href="manip.html" title="cpp/io/manip"> I/O manipulators</a></td></tr>
304
304
+
<tr class="t-nv"><td colspan="5"> <a href="../io.html#Print_functions_.28since_C.2B.2B23.29" title="cpp/io"> Print functions</a> <span class="t-mark-rev t-since-cxx23">(C++23)</span></td></tr>
305
305
+
<tr class="t-nv"><td colspan="5"> <a href="c.html" title="cpp/io/c"> C-style I/O</a></td></tr>
306
306
+
<tr class="t-nv-h1"><td colspan="5"> Buffers</td></tr>
307
307
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_streambuf.html" title="cpp/io/basic streambuf"><span class="t-lines"><span>basic_streambuf</span></span></a></div></div></td></tr>
308
308
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_filebuf.html" title="cpp/io/basic filebuf"><span class="t-lines"><span>basic_filebuf</span></span></a></div></div></td></tr>
309
309
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_stringbuf.html" title="cpp/io/basic stringbuf"><span class="t-lines"><span>basic_stringbuf</span></span></a></div></div></td></tr>
310
310
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_spanbuf.html" title="cpp/io/basic spanbuf"><span class="t-lines"><span>basic_spanbuf</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
311
311
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="strstreambuf.html" title="cpp/io/strstreambuf"><span class="t-lines"><span>strstreambuf</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-deprecated-cxx98">(deprecated in C++98)</span></span></span></div></div></td></tr>
312
312
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_syncbuf.html" title="cpp/io/basic syncbuf"><span class="t-lines"><span>basic_syncbuf</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
313
313
+
<tr class="t-nv-h1"><td colspan="5"> Streams</td></tr>
314
314
+
<tr class="t-nv-h2"><td colspan="5"> Abstractions</td></tr>
315
315
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ios_base.html" title="cpp/io/ios base"><span class="t-lines"><span>ios_base</span></span></a></div></div></td></tr>
316
316
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ios.html" title="cpp/io/basic ios"><span class="t-lines"><span>basic_ios</span></span></a></div></div></td></tr>
317
317
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream.html" title="cpp/io/basic istream"><span class="t-lines"><span>basic_istream</span></span></a></div></div></td></tr>
318
318
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ostream.html" title="cpp/io/basic ostream"><span class="t-lines"><span>basic_ostream</span></span></a></div></div></td></tr>
319
319
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_iostream.html" title="cpp/io/basic iostream"><span class="t-lines"><span>basic_iostream</span></span></a></div></div></td></tr>
320
320
+
<tr class="t-nv-h2"><td colspan="5"> File I/O</td></tr>
321
321
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><strong class="selflink"><span class="t-lines"><span>basic_ifstream</span></span></strong></div></div></td></tr>
322
322
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ofstream.html" title="cpp/io/basic ofstream"><span class="t-lines"><span>basic_ofstream</span></span></a></div></div></td></tr>
323
323
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_fstream.html" title="cpp/io/basic fstream"><span class="t-lines"><span>basic_fstream</span></span></a></div></div></td></tr>
324
324
+
<tr class="t-nv-h2"><td colspan="5"> String I/O</td></tr>
325
325
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istringstream.html" title="cpp/io/basic istringstream"><span class="t-lines"><span>basic_istringstream</span></span></a></div></div></td></tr>
326
326
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ostringstream.html" title="cpp/io/basic ostringstream"><span class="t-lines"><span>basic_ostringstream</span></span></a></div></div></td></tr>
327
327
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_stringstream.html" title="cpp/io/basic stringstream"><span class="t-lines"><span>basic_stringstream</span></span></a></div></div></td></tr>
328
328
+
<tr class="t-nv-h2"><td colspan="5"> Array I/O</td></tr>
329
329
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ispanstream.html" title="cpp/io/basic ispanstream"><span class="t-lines"><span>basic_ispanstream</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
330
330
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ospanstream.html" title="cpp/io/basic ospanstream"><span class="t-lines"><span>basic_ospanstream</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
331
331
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_spanstream.html" title="cpp/io/basic spanstream"><span class="t-lines"><span>basic_spanstream</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
332
332
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="istrstream.html" title="cpp/io/istrstream"><span class="t-lines"><span>istrstream</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-deprecated-cxx98">(deprecated in C++98)</span></span></span></div></div></td></tr>
333
333
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ostrstream.html" title="cpp/io/ostrstream"><span class="t-lines"><span>ostrstream</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-deprecated-cxx98">(deprecated in C++98)</span></span></span></div></div></td></tr>
334
334
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="strstream.html" title="cpp/io/strstream"><span class="t-lines"><span>strstream</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-deprecated-cxx98">(deprecated in C++98)</span></span></span></div></div></td></tr>
335
335
+
<tr class="t-nv-h2"><td colspan="5"> Synchronized Output</td></tr>
336
336
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_osyncstream.html" title="cpp/io/basic osyncstream"><span class="t-lines"><span>basic_osyncstream</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
337
337
+
<tr class="t-nv-h1"><td colspan="5"> Types</td></tr>
338
338
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="streamoff.html" title="cpp/io/streamoff"><span class="t-lines"><span>streamoff</span></span></a></div></div></td></tr>
339
339
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="streamsize.html" title="cpp/io/streamsize"><span class="t-lines"><span>streamsize</span></span></a></div></div></td></tr>
340
340
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fpos.html" title="cpp/io/fpos"><span class="t-lines"><span>fpos</span></span></a></div></div></td></tr>
341
341
+
<tr class="t-nv-h1"><td colspan="5"> Error category interface</td></tr>
342
342
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="iostream_category.html" title="cpp/io/iostream category"><span class="t-lines"><span>iostream_category</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
343
343
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="io_errc.html" title="cpp/io/io errc"><span class="t-lines"><span>io_errc</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
344
344
+
</table></div><div><span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/navbar_content&action=edit">[edit]</a></span></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><strong class="selflink"><tt>std::basic_ifstream</tt></strong><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
345
345
+
<tr class="t-nv-h1"><td colspan="5"> Member functions</td></tr>
346
346
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ifstream/basic_ifstream.html" title="cpp/io/basic ifstream/basic ifstream"><span class="t-lines"><span>basic_ifstream::basic_ifstream</span></span></a></div></div></td></tr>
347
347
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ifstream/operator=.html" title="cpp/io/basic ifstream/operator="><span class="t-lines"><span>basic_ifstream::operator=</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
348
348
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ifstream/swap.html" title="cpp/io/basic ifstream/swap"><span class="t-lines"><span>basic_ifstream::swap</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
349
349
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ifstream/rdbuf.html" title="cpp/io/basic ifstream/rdbuf"><span class="t-lines"><span>basic_ifstream::rdbuf</span></span></a></div></div></td></tr>
350
350
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ifstream/native_handle.html" title="cpp/io/basic ifstream/native handle"><span class="t-lines"><span>basic_ifstream::native_handle</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx26">(C++26)</span></span></span></div></div></td></tr>
351
351
+
<tr class="t-nv-h2"><td colspan="5"> File operations </td></tr>
352
352
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ifstream/is_open.html" title="cpp/io/basic ifstream/is open"><span class="t-lines"><span>basic_ifstream::is_open</span></span></a></div></div></td></tr>
353
353
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ifstream/open.html" title="cpp/io/basic ifstream/open"><span class="t-lines"><span>basic_ifstream::open</span></span></a></div></div></td></tr>
354
354
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ifstream/close.html" title="cpp/io/basic ifstream/close"><span class="t-lines"><span>basic_ifstream::close</span></span></a></div></div></td></tr>
355
355
+
<tr class="t-nv-h1"><td colspan="5"> Non-member functions </td></tr>
356
356
+
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ifstream/swap2.html" title="cpp/io/basic ifstream/swap2"><span class="t-lines"><span>swap<span class="t-dsc-small">(std::basic_ifstream)</span></span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
357
357
+
</table></div><div><span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ifstream/navbar_content&action=edit">[edit]</a></span></div></div></div></div><div class="t-navbar-sep"> </div></div>
358
358
+
<table class="t-dcl-begin"><tbody>
359
359
+
<tr class="t-dsc-header">
360
360
+
<td> <div>Defined in header <code><a href="../header/fstream.html" title="cpp/header/fstream"><fstream></a></code>
361
361
+
</div></td>
362
362
+
<td></td>
363
363
+
<td></td>
364
364
+
</tr>
365
365
+
<tr class="t-dcl">
366
366
+
<td class="t-dcl-nopad"> <div><span class="mw-geshi cpp source-cpp"><span class="kw1">template</span><span class="sy1"><</span> <br />
367
367
+
<p>    <span class="kw1">class</span> CharT, <br />
368
368
+
    <span class="kw1">class</span> Traits <span class="sy1">=</span> <a href="../string/char_traits.html"><span class="kw1270">std::<span class="me2">char_traits</span></span></a><span class="sy1"><</span>CharT<span class="sy1">></span><br />
369
369
+
</p>
370
370
+
<span class="sy1">></span> <span class="kw1">class</span> basic_ifstream <span class="sy4">:</span> <span class="kw1">public</span> <a href="basic_istream.html"><span class="kw1717">std::<span class="me2">basic_istream</span></span></a><span class="sy1"><</span>CharT, Traits<span class="sy1">></span></span></div></td>
371
371
+
<td class="t-dcl-nopad"> </td>
372
372
+
<td class="t-dcl-nopad"> </td>
373
373
+
</tr>
374
374
+
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
375
375
+
</tbody></table>
376
376
+
<p>The class template <code>basic_ifstream</code> implements high-level input operations on file-based streams. It interfaces a file-based streambuffer (<span class="t-lc"><a href="basic_filebuf.html" title="cpp/io/basic filebuf">std::basic_filebuf</a></span>) with the high-level interface of (<span class="t-lc"><a href="basic_istream.html" title="cpp/io/basic istream">std::basic_istream</a></span>).
377
377
+
</p><p>A typical implementation of <code>std::basic_ifstream</code> holds only one non-derived data member: an instance of <span class="mw-geshi cpp source-cpp"><a href="basic_filebuf.html"><span class="kw1671">std::<span class="me2">basic_filebuf</span></span></a><span class="sy1"><</span>CharT, Traits<span class="sy1">></span></span>.
378
378
+
</p>
379
379
+
<div class="t-inheritance-diagram">
380
380
+
<div class="center"><div class="noresize"><map name="ImageMap_1_1582003816"><area href="ios_base.html" shape="rect" coords="5,6,107,39" alt="cpp/io/ios base" title="cpp/io/ios base"/><area href="basic_ios.html" shape="rect" coords="135,4,252,42" alt="cpp/io/basic ios" title="cpp/io/basic ios"/><area href="basic_istream.html" shape="rect" coords="278,4,395,42" alt="cpp/io/basic istream" title="cpp/io/basic istream"/></map><img alt="std-basic ifstream-inheritance.svg" src="../../../../upload.cppreference.com/mwiki/images/7/79/std-basic_ifstream-inheritance.svg" width="543" height="45" usemap="#ImageMap_1_1582003816"/></div></div>
381
381
+
<div style="text-align:center;">
382
382
+
<p><span style="font-size:0.7em; line-height:130%">Inheritance diagram</span>
383
383
+
</p>
384
384
+
</div>
385
385
+
</div>
386
386
+
<p>Several typedefs for common character types are provided:
387
387
+
</p>
388
388
+
<table class="t-dsc-begin">
389
389
+
390
390
+
<tr class="t-dsc-header">
391
391
+
<td colspan="2"> <div>Defined in header <code><a href="../header/fstream.html" title="cpp/header/fstream"><fstream></a></code> </div>
392
392
+
</td></tr>
393
393
+
394
394
+
<tr class="t-dsc-hitem">
395
395
+
<td> Type
396
396
+
</td>
397
397
+
<td> Definition
398
398
+
</td></tr>
399
399
+
400
400
+
401
401
+
<tr class="t-dsc">
402
402
+
<td> <code>std::ifstream</code>
403
403
+
</td>
404
404
+
<td> <span class="mw-geshi cpp source-cpp">std<span class="sy4">::</span><span class="me2">basic_ifstream</span><span class="sy1"><</span><span class="kw4">char</span><span class="sy1">></span></span>
405
405
+
</td></tr>
406
406
+
407
407
+
408
408
+
<tr class="t-dsc">
409
409
+
<td> <code>std::wifstream</code>
410
410
+
</td>
411
411
+
<td> <span class="mw-geshi cpp source-cpp">std<span class="sy4">::</span><span class="me2">basic_ifstream</span><span class="sy1"><</span><span class="kw4">wchar_t</span><span class="sy1">></span></span>
412
412
+
</td></tr>
413
413
+
414
414
+
</table>
415
415
+
<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div>
416
416
+
<ul>
417
417
+
<li class="toclevel-1"><a href="basic_ifstream.html#Member_types"><span class="tocnumber">1</span> <span class="toctext">Member types</span></a></li>
418
418
+
<li class="toclevel-1 tocsection-1"><a href="basic_ifstream.html#Member_functions"><span class="tocnumber">2</span> <span class="toctext">Member functions</span></a>
419
419
+
<ul>
420
420
+
<li class="toclevel-2"><a href="basic_ifstream.html#File_operations"><span class="tocnumber">2.1</span> <span class="toctext">File operations</span></a></li>
421
421
+
</ul>
422
422
+
</li>
423
423
+
<li class="toclevel-1 tocsection-2"><a href="basic_ifstream.html#Non-member_functions"><span class="tocnumber">3</span> <span class="toctext">Non-member functions</span></a></li>
424
424
+
<li class="toclevel-1"><a href="basic_ifstream.html#Inherited_from_std::basic_istream"><span class="tocnumber">4</span> <span class="toctext">Inherited from <span>std::</span>basic_istream</span></a>
425
425
+
<ul>
426
426
+
<li class="toclevel-2"><a href="basic_ifstream.html#Member_functions_2"><span class="tocnumber">4.1</span> <span class="toctext">Member functions</span></a>
427
427
+
<ul>
428
428
+
<li class="toclevel-3"><a href="basic_ifstream.html#Formatted_input"><span class="tocnumber">4.1.1</span> <span class="toctext">Formatted input</span></a></li>
429
429
+
<li class="toclevel-3"><a href="basic_ifstream.html#Unformatted_input"><span class="tocnumber">4.1.2</span> <span class="toctext">Unformatted input</span></a></li>
430
430
+
<li class="toclevel-3"><a href="basic_ifstream.html#Positioning"><span class="tocnumber">4.1.3</span> <span class="toctext">Positioning</span></a></li>
431
431
+
<li class="toclevel-3"><a href="basic_ifstream.html#Miscellaneous"><span class="tocnumber">4.1.4</span> <span class="toctext">Miscellaneous</span></a></li>
432
432
+
</ul>
433
433
+
</li>
434
434
+
<li class="toclevel-2"><a href="basic_ifstream.html#Member_classes"><span class="tocnumber">4.2</span> <span class="toctext">Member classes</span></a></li>
435
435
+
</ul>
436
436
+
</li>
437
437
+
<li class="toclevel-1"><a href="basic_ifstream.html#Inherited_from_std::basic_ios"><span class="tocnumber">5</span> <span class="toctext">Inherited from <span>std::</span>basic_ios</span></a>
438
438
+
<ul>
439
439
+
<li class="toclevel-2"><a href="basic_ifstream.html#Member_types_2"><span class="tocnumber">5.1</span> <span class="toctext">Member types</span></a></li>
440
440
+
<li class="toclevel-2"><a href="basic_ifstream.html#Member_functions_3"><span class="tocnumber">5.2</span> <span class="toctext">Member functions</span></a>
441
441
+
<ul>
442
442
+
<li class="toclevel-3"><a href="basic_ifstream.html#State_functions"><span class="tocnumber">5.2.1</span> <span class="toctext">State functions</span></a></li>
443
443
+
<li class="toclevel-3"><a href="basic_ifstream.html#Formatting"><span class="tocnumber">5.2.2</span> <span class="toctext">Formatting</span></a></li>
444
444
+
<li class="toclevel-3"><a href="basic_ifstream.html#Miscellaneous_2"><span class="tocnumber">5.2.3</span> <span class="toctext">Miscellaneous</span></a></li>
445
445
+
</ul>
446
446
+
</li>
447
447
+
</ul>
448
448
+
</li>
449
449
+
<li class="toclevel-1"><a href="basic_ifstream.html#Inherited_from_std::ios_base"><span class="tocnumber">6</span> <span class="toctext">Inherited from <span>std::</span>ios_base</span></a>
450
450
+
<ul>
451
451
+
<li class="toclevel-2"><a href="basic_ifstream.html#Member_functions_4"><span class="tocnumber">6.1</span> <span class="toctext">Member functions</span></a>
452
452
+
<ul>
453
453
+
<li class="toclevel-3"><a href="basic_ifstream.html#Formatting_2"><span class="tocnumber">6.1.1</span> <span class="toctext">Formatting</span></a></li>
454
454
+
<li class="toclevel-3"><a href="basic_ifstream.html#Locales"><span class="tocnumber">6.1.2</span> <span class="toctext">Locales</span></a></li>
455
455
+
<li class="toclevel-3"><a href="basic_ifstream.html#Internal_extensible_array"><span class="tocnumber">6.1.3</span> <span class="toctext">Internal extensible array</span></a></li>
456
456
+
<li class="toclevel-3"><a href="basic_ifstream.html#Miscellaneous_3"><span class="tocnumber">6.1.4</span> <span class="toctext">Miscellaneous</span></a></li>
457
457
+
<li class="toclevel-3"><a href="basic_ifstream.html#Member_classes_2"><span class="tocnumber">6.1.5</span> <span class="toctext">Member classes</span></a></li>
458
458
+
</ul>
459
459
+
</li>
460
460
+
<li class="toclevel-2"><a href="basic_ifstream.html#Member_types_and_constants"><span class="tocnumber">6.2</span> <span class="toctext">Member types and constants</span></a></li>
461
461
+
<li class="toclevel-2 tocsection-3"><a href="basic_ifstream.html#Notes"><span class="tocnumber">6.3</span> <span class="toctext">Notes</span></a></li>
462
462
+
<li class="toclevel-2 tocsection-4"><a href="basic_ifstream.html#Example"><span class="tocnumber">6.4</span> <span class="toctext">Example</span></a></li>
463
463
+
</ul>
464
464
+
</li>
465
465
+
</ul>
466
466
+
</td></tr></table>
467
467
+
<h3><span class="editsection">[<a href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/member_types&action=edit&section=T-1" title="Template:cpp/io/member types">edit</a>]</span> <span class="mw-headline" id="Member_types">Member types</span></h3>
468
468
+
<table class="t-dsc-begin">
469
469
+
470
470
+
<tr class="t-dsc-hitem">
471
471
+
<td> Member type
472
472
+
</td>
473
473
+
<td> Definition
474
474
+
</td></tr>
475
475
+
476
476
+
477
477
+
<tr class="t-dsc">
478
478
+
<td> <code>char_type</code>
479
479
+
</td>
480
480
+
<td> <code>CharT</code><span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/dsc_char_type&action=edit">[edit]</a></span>
481
481
+
</td></tr>
482
482
+
483
483
+
<tr class="t-dsc">
484
484
+
<td> <code>traits_type</code>
485
485
+
</td>
486
486
+
<td> <code>Traits</code>; the program is ill-formed if <code>Traits::char_type</code> is not <code>CharT</code>.<span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/dsc_traits_type&action=edit">[edit]</a></span>
487
487
+
</td></tr>
488
488
+
489
489
+
<tr class="t-dsc">
490
490
+
<td> <code>int_type</code>
491
491
+
</td>
492
492
+
<td> <code>Traits::int_type</code><span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/dsc_int_type&action=edit">[edit]</a></span>
493
493
+
</td></tr>
494
494
+
495
495
+
<tr class="t-dsc">
496
496
+
<td> <code>pos_type</code>
497
497
+
</td>
498
498
+
<td> <code>Traits::pos_type</code><span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/dsc_pos_type&action=edit">[edit]</a></span>
499
499
+
</td></tr>
500
500
+
501
501
+
<tr class="t-dsc">
502
502
+
<td> <code>off_type</code>
503
503
+
</td>
504
504
+
<td> <code>Traits::off_type</code><span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/dsc_off_type&action=edit">[edit]</a></span>
505
505
+
</td></tr>
506
506
+
507
507
+
<tr class="t-dsc">
508
508
+
<td> <code>native_handle_type</code><span class="t-mark-rev t-since-cxx26">(C++26)</span>
509
509
+
</td>
510
510
+
<td> <i>implementation-defined</i> type that is <a href="../named_req/TriviallyCopyable.html" title="cpp/named req/TriviallyCopyable"><span style="font-family: Georgia, 'DejaVu Serif', serif; font-style:italic">TriviallyCopyable</span></a> and <a href="../concepts/semiregular.html" title="cpp/concepts/semiregular"><code>semiregular</code></a><span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/dsc_native_handle_type&action=edit">[edit]</a></span>
511
511
+
</td></tr>
512
512
+
</table>
513
513
+
<h3><span class="editsection">[<a href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&action=edit&section=1" title="Edit section: Member functions">edit</a>]</span> <span class="mw-headline" id="Member_functions">Member functions</span></h3>
514
514
+
<table class="t-dsc-begin">
515
515
+
516
516
+
<tr class="t-dsc">
517
517
+
<td> <div class="t-dsc-member-div t-dsc-member-nobold-div"><div><a href="basic_ifstream/basic_ifstream.html" title="cpp/io/basic ifstream/basic ifstream"> <span class="t-lines"><span>(constructor)</span></span></a></div></div>
518
518
+
</td>
519
519
+
<td> constructs the file stream <br /> <span class="t-mark">(public member function)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_fstream/dsc_constructor&action=edit">[edit]</a></span>
520
520
+
</td></tr>
521
521
+
522
522
+
<tr class="t-dsc">
523
523
+
<td> <div class="t-dsc-member-div t-dsc-member-nobold-div"><div><span class="t-lines"><span>(destructor)</span></span></div><div><span class="t-lines"><span><span class="t-cmark">[virtual]</span> <span class="t-mark">(implicitly declared)</span></span></span></div></div>
524
524
+
</td>
525
525
+
<td> destructs the <code>basic_ifstream</code> and the associated buffer, closes the file <br /> <span class="t-mark">(virtual public member function)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_fstream/dsc_destructor&action=edit">[edit]</a></span>
526
526
+
</td></tr>
527
527
+
528
528
+
<tr class="t-dsc">
529
529
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ifstream/operator=.html" title="cpp/io/basic ifstream/operator="> <span class="t-lines"><span>operator=</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
530
530
+
</td>
531
531
+
<td> moves the file stream <br /> <span class="t-mark">(public member function)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_fstream/dsc_operator%3D&action=edit">[edit]</a></span>
532
532
+
</td></tr>
533
533
+
534
534
+
<tr class="t-dsc">
535
535
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ifstream/swap.html" title="cpp/io/basic ifstream/swap"> <span class="t-lines"><span>swap</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
536
536
+
</td>
537
537
+
<td> swaps two file streams <br /> <span class="t-mark">(public member function)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_fstream/dsc_swap&action=edit">[edit]</a></span>
538
538
+
</td></tr>
539
539
+
540
540
+
<tr class="t-dsc">
541
541
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ifstream/rdbuf.html" title="cpp/io/basic ifstream/rdbuf"> <span class="t-lines"><span>rdbuf</span></span></a></div></div>
542
542
+
</td>
543
543
+
<td> returns the underlying raw file device object <br /> <span class="t-mark">(public member function)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_fstream/dsc_rdbuf&action=edit">[edit]</a></span>
544
544
+
</td></tr>
545
545
+
546
546
+
<tr class="t-dsc">
547
547
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ifstream/native_handle.html" title="cpp/io/basic ifstream/native handle"> <span class="t-lines"><span>native_handle</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx26">(C++26)</span></span></span></div></div>
548
548
+
</td>
549
549
+
<td> returns the underlying implementation-defined handle <br /> <span class="t-mark">(public member function)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ifstream/dsc_native_handle&action=edit">[edit]</a></span>
550
550
+
</td></tr>
551
551
+
552
552
+
553
553
+
<tr>
554
554
+
<td colspan="2"> <h5> <span class="mw-headline" id="File_operations"> File operations </span></h5>
555
555
+
</td></tr>
556
556
+
557
557
+
<tr class="t-dsc">
558
558
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ifstream/is_open.html" title="cpp/io/basic ifstream/is open"> <span class="t-lines"><span>is_open</span></span></a></div></div>
559
559
+
</td>
560
560
+
<td> checks if the stream has an associated file <br /> <span class="t-mark">(public member function)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_fstream/dsc_is_open&action=edit">[edit]</a></span>
561
561
+
</td></tr>
562
562
+
563
563
+
<tr class="t-dsc">
564
564
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ifstream/open.html" title="cpp/io/basic ifstream/open"> <span class="t-lines"><span>open</span></span></a></div></div>
565
565
+
</td>
566
566
+
<td> opens a file and associates it with the stream <br /> <span class="t-mark">(public member function)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_fstream/dsc_open&action=edit">[edit]</a></span>
567
567
+
</td></tr>
568
568
+
569
569
+
<tr class="t-dsc">
570
570
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ifstream/close.html" title="cpp/io/basic ifstream/close"> <span class="t-lines"><span>close</span></span></a></div></div>
571
571
+
</td>
572
572
+
<td> closes the associated file <br /> <span class="t-mark">(public member function)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_fstream/dsc_close&action=edit">[edit]</a></span>
573
573
+
</td></tr>
574
574
+
</table>
575
575
+
<h3><span class="editsection">[<a href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&action=edit&section=2" title="Edit section: Non-member functions">edit</a>]</span> <span class="mw-headline" id="Non-member_functions">Non-member functions</span></h3>
576
576
+
<table class="t-dsc-begin">
577
577
+
578
578
+
<tr class="t-dsc">
579
579
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ifstream/swap2.html" title="cpp/io/basic ifstream/swap2"> <span class="t-lines"><span>std::swap<span class="t-dsc-small">(std::basic_ifstream)</span></span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
580
580
+
</td>
581
581
+
<td> specializes the <span class="t-lc"><a href="../algorithm/swap.html" title="cpp/algorithm/swap">std::swap</a></span> algorithm <br /> <span class="t-mark">(function template)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_fstream/dsc_swap2&action=edit">[edit]</a></span>
582
582
+
</td></tr>
583
583
+
</table>
584
584
+
<div class="t-inherited">
585
585
+
<h2> <span class="mw-headline" id="Inherited_from_std::basic_istream">Inherited from <a href="basic_istream.html" title="cpp/io/basic istream"> <span style="font-size:0.7em; line-height:130%">std::</span>basic_istream</a> </span></h2>
586
586
+
<h3> <span class="mw-headline" id="Member_functions_2">Member functions</span></h3>
587
587
+
<table class="t-dsc-begin">
588
588
+
589
589
+
<tr>
590
590
+
<td colspan="2"> <h5> <span class="mw-headline" id="Formatted_input"> Formatted input </span></h5>
591
591
+
</td></tr>
592
592
+
593
593
+
<tr class="t-dsc">
594
594
+
<td> <div class="t-dsc-member-div"><div><a href="basic_istream/operator_gtgt.html" title="cpp/io/basic istream/operator gtgt"> <span class="t-lines"><span>operator>></span></span></a></div></div>
595
595
+
</td>
596
596
+
<td> extracts formatted data <br /> <span class="t-mark">(public member function of <code>std::basic_istream<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_istream/dsc_operator_gtgt&action=edit">[edit]</a></span>
597
597
+
</td></tr>
598
598
+
599
599
+
600
600
+
<tr>
601
601
+
<td colspan="2"> <h5> <span class="mw-headline" id="Unformatted_input"> Unformatted input </span></h5>
602
602
+
</td></tr>
603
603
+
604
604
+
<tr class="t-dsc">
605
605
+
<td> <div class="t-dsc-member-div"><div><a href="basic_istream/get.html" title="cpp/io/basic istream/get"> <span class="t-lines"><span>get</span></span></a></div></div>
606
606
+
</td>
607
607
+
<td> extracts characters <br /> <span class="t-mark">(public member function of <code>std::basic_istream<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_istream/dsc_get&action=edit">[edit]</a></span>
608
608
+
</td></tr>
609
609
+
610
610
+
<tr class="t-dsc">
611
611
+
<td> <div class="t-dsc-member-div"><div><a href="basic_istream/peek.html" title="cpp/io/basic istream/peek"> <span class="t-lines"><span>peek</span></span></a></div></div>
612
612
+
</td>
613
613
+
<td> reads the next character without extracting it <br /> <span class="t-mark">(public member function of <code>std::basic_istream<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_istream/dsc_peek&action=edit">[edit]</a></span>
614
614
+
</td></tr>
615
615
+
616
616
+
<tr class="t-dsc">
617
617
+
<td> <div class="t-dsc-member-div"><div><a href="basic_istream/unget.html" title="cpp/io/basic istream/unget"> <span class="t-lines"><span>unget</span></span></a></div></div>
618
618
+
</td>
619
619
+
<td> unextracts a character <br /> <span class="t-mark">(public member function of <code>std::basic_istream<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_istream/dsc_unget&action=edit">[edit]</a></span>
620
620
+
</td></tr>
621
621
+
622
622
+
<tr class="t-dsc">
623
623
+
<td> <div class="t-dsc-member-div"><div><a href="basic_istream/putback.html" title="cpp/io/basic istream/putback"> <span class="t-lines"><span>putback</span></span></a></div></div>
624
624
+
</td>
625
625
+
<td> puts a character into input stream <br /> <span class="t-mark">(public member function of <code>std::basic_istream<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_istream/dsc_putback&action=edit">[edit]</a></span>
626
626
+
</td></tr>
627
627
+
628
628
+
<tr class="t-dsc">
629
629
+
<td> <div class="t-dsc-member-div"><div><a href="basic_istream/getline.html" title="cpp/io/basic istream/getline"> <span class="t-lines"><span>getline</span></span></a></div></div>
630
630
+
</td>
631
631
+
<td> extracts characters until the given character is found <br /> <span class="t-mark">(public member function of <code>std::basic_istream<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_istream/dsc_getline&action=edit">[edit]</a></span>
632
632
+
</td></tr>
633
633
+
634
634
+
<tr class="t-dsc">
635
635
+
<td> <div class="t-dsc-member-div"><div><a href="basic_istream/ignore.html" title="cpp/io/basic istream/ignore"> <span class="t-lines"><span>ignore</span></span></a></div></div>
636
636
+
</td>
637
637
+
<td> extracts and discards characters until the given character is found <br /> <span class="t-mark">(public member function of <code>std::basic_istream<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_istream/dsc_ignore&action=edit">[edit]</a></span>
638
638
+
</td></tr>
639
639
+
640
640
+
<tr class="t-dsc">
641
641
+
<td> <div class="t-dsc-member-div"><div><a href="basic_istream/read.html" title="cpp/io/basic istream/read"> <span class="t-lines"><span>read</span></span></a></div></div>
642
642
+
</td>
643
643
+
<td> extracts blocks of characters <br /> <span class="t-mark">(public member function of <code>std::basic_istream<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_istream/dsc_read&action=edit">[edit]</a></span>
644
644
+
</td></tr>
645
645
+
646
646
+
<tr class="t-dsc">
647
647
+
<td> <div class="t-dsc-member-div"><div><a href="basic_istream/readsome.html" title="cpp/io/basic istream/readsome"> <span class="t-lines"><span>readsome</span></span></a></div></div>
648
648
+
</td>
649
649
+
<td> extracts already available blocks of characters <br /> <span class="t-mark">(public member function of <code>std::basic_istream<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_istream/dsc_readsome&action=edit">[edit]</a></span>
650
650
+
</td></tr>
651
651
+
652
652
+
<tr class="t-dsc">
653
653
+
<td> <div class="t-dsc-member-div"><div><a href="basic_istream/gcount.html" title="cpp/io/basic istream/gcount"> <span class="t-lines"><span>gcount</span></span></a></div></div>
654
654
+
</td>
655
655
+
<td> returns number of characters extracted by last unformatted input operation <br /> <span class="t-mark">(public member function of <code>std::basic_istream<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_istream/dsc_gcount&action=edit">[edit]</a></span>
656
656
+
</td></tr>
657
657
+
658
658
+
659
659
+
<tr>
660
660
+
<td colspan="2"> <h5> <span class="mw-headline" id="Positioning"> Positioning </span></h5>
661
661
+
</td></tr>
662
662
+
663
663
+
<tr class="t-dsc">
664
664
+
<td> <div class="t-dsc-member-div"><div><a href="basic_istream/tellg.html" title="cpp/io/basic istream/tellg"> <span class="t-lines"><span>tellg</span></span></a></div></div>
665
665
+
</td>
666
666
+
<td> returns the input position indicator <br /> <span class="t-mark">(public member function of <code>std::basic_istream<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_istream/dsc_tellg&action=edit">[edit]</a></span>
667
667
+
</td></tr>
668
668
+
669
669
+
<tr class="t-dsc">
670
670
+
<td> <div class="t-dsc-member-div"><div><a href="basic_istream/seekg.html" title="cpp/io/basic istream/seekg"> <span class="t-lines"><span>seekg</span></span></a></div></div>
671
671
+
</td>
672
672
+
<td> sets the input position indicator <br /> <span class="t-mark">(public member function of <code>std::basic_istream<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_istream/dsc_seekg&action=edit">[edit]</a></span>
673
673
+
</td></tr>
674
674
+
675
675
+
676
676
+
<tr>
677
677
+
<td colspan="2"> <h5> <span class="mw-headline" id="Miscellaneous"> Miscellaneous </span></h5>
678
678
+
</td></tr>
679
679
+
680
680
+
<tr class="t-dsc">
681
681
+
<td> <div class="t-dsc-member-div"><div><a href="basic_istream/sync.html" title="cpp/io/basic istream/sync"> <span class="t-lines"><span>sync</span></span></a></div></div>
682
682
+
</td>
683
683
+
<td> synchronizes with the underlying storage device <br /> <span class="t-mark">(public member function of <code>std::basic_istream<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_istream/dsc_sync&action=edit">[edit]</a></span>
684
684
+
</td></tr>
685
685
+
</table>
686
686
+
<h3> <span class="mw-headline" id="Member_classes">Member classes</span></h3>
687
687
+
<table class="t-dsc-begin">
688
688
+
689
689
+
<tr class="t-dsc">
690
690
+
<td> <div class="t-dsc-member-div"><div><a href="basic_istream/sentry.html" title="cpp/io/basic istream/sentry"> <span class="t-lines"><span>sentry</span></span></a></div></div>
691
691
+
</td>
692
692
+
<td> implements basic logic for preparation of the stream for input operations <br /> <span class="t-mark">(public member class of <code>std::basic_istream<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_istream/dsc_sentry&action=edit">[edit]</a></span>
693
693
+
</td></tr>
694
694
+
</table>
695
695
+
</div>
696
696
+
<div class="t-inherited">
697
697
+
<h2> <span class="mw-headline" id="Inherited_from_std::basic_ios">Inherited from <a href="basic_ios.html" title="cpp/io/basic ios"> <span style="font-size:0.7em; line-height:130%">std::</span>basic_ios</a> </span></h2>
698
698
+
<h3> <span class="mw-headline" id="Member_types_2">Member types</span></h3>
699
699
+
<table class="t-dsc-begin">
700
700
+
701
701
+
<tr class="t-dsc-hitem">
702
702
+
<td> Member type
703
703
+
</td>
704
704
+
<td> Definition
705
705
+
</td></tr>
706
706
+
707
707
+
708
708
+
<tr class="t-dsc">
709
709
+
<td> <code>char_type</code>
710
710
+
</td>
711
711
+
<td> <code>CharT</code>
712
712
+
</td></tr>
713
713
+
714
714
+
715
715
+
<tr class="t-dsc">
716
716
+
<td> <code>traits_type</code>
717
717
+
</td>
718
718
+
<td> <code>Traits</code>
719
719
+
</td></tr>
720
720
+
721
721
+
722
722
+
<tr class="t-dsc">
723
723
+
<td> <code>int_type</code>
724
724
+
</td>
725
725
+
<td> <code>Traits::int_type</code>
726
726
+
</td></tr>
727
727
+
728
728
+
729
729
+
<tr class="t-dsc">
730
730
+
<td> <code>pos_type</code>
731
731
+
</td>
732
732
+
<td> <code>Traits::pos_type</code>
733
733
+
</td></tr>
734
734
+
735
735
+
736
736
+
<tr class="t-dsc">
737
737
+
<td> <code>off_type</code>
738
738
+
</td>
739
739
+
<td> <code>Traits::off_type</code>
740
740
+
</td></tr>
741
741
+
742
742
+
</table>
743
743
+
<h3> <span class="mw-headline" id="Member_functions_3">Member functions</span></h3>
744
744
+
<table class="t-dsc-begin">
745
745
+
746
746
+
<tr>
747
747
+
<td colspan="2"> <h5> <span class="mw-headline" id="State_functions"> State functions </span></h5>
748
748
+
</td></tr>
749
749
+
750
750
+
<tr class="t-dsc">
751
751
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ios/good.html" title="cpp/io/basic ios/good"> <span class="t-lines"><span>good</span></span></a></div></div>
752
752
+
</td>
753
753
+
<td> checks if no error has occurred i.e. I/O operations are available <br /> <span class="t-mark">(public member function of <code>std::basic_ios<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ios/dsc_good&action=edit">[edit]</a></span>
754
754
+
</td></tr>
755
755
+
756
756
+
<tr class="t-dsc">
757
757
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ios/eof.html" title="cpp/io/basic ios/eof"> <span class="t-lines"><span>eof</span></span></a></div></div>
758
758
+
</td>
759
759
+
<td> checks if end-of-file has been reached <br /> <span class="t-mark">(public member function of <code>std::basic_ios<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ios/dsc_eof&action=edit">[edit]</a></span>
760
760
+
</td></tr>
761
761
+
762
762
+
<tr class="t-dsc">
763
763
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ios/fail.html" title="cpp/io/basic ios/fail"> <span class="t-lines"><span>fail</span></span></a></div></div>
764
764
+
</td>
765
765
+
<td> checks if an error has occurred <br /> <span class="t-mark">(public member function of <code>std::basic_ios<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ios/dsc_fail&action=edit">[edit]</a></span>
766
766
+
</td></tr>
767
767
+
768
768
+
<tr class="t-dsc">
769
769
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ios/bad.html" title="cpp/io/basic ios/bad"> <span class="t-lines"><span>bad</span></span></a></div></div>
770
770
+
</td>
771
771
+
<td> checks if a non-recoverable error has occurred <br /> <span class="t-mark">(public member function of <code>std::basic_ios<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ios/dsc_bad&action=edit">[edit]</a></span>
772
772
+
</td></tr>
773
773
+
774
774
+
<tr class="t-dsc">
775
775
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ios/operator!.html" title="cpp/io/basic ios/operator!"> <span class="t-lines"><span>operator!</span></span></a></div></div>
776
776
+
</td>
777
777
+
<td> checks if an error has occurred (synonym of <span class="t-lc"><a href="basic_ios/fail.html" title="cpp/io/basic ios/fail">fail()</a></span>) <br /> <span class="t-mark">(public member function of <code>std::basic_ios<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ios/dsc_operator!&action=edit">[edit]</a></span>
778
778
+
</td></tr>
779
779
+
780
780
+
<tr class="t-dsc">
781
781
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ios/operator_bool.html" title="cpp/io/basic ios/operator bool"> <span class="t-lines"><span>operator bool</span></span></a></div></div>
782
782
+
</td>
783
783
+
<td> checks if no error has occurred (synonym of <code>!</code><span class="t-lc"><a href="basic_ios/fail.html" title="cpp/io/basic ios/fail">fail()</a></span>) <br /> <span class="t-mark">(public member function of <code>std::basic_ios<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ios/dsc_operator_bool&action=edit">[edit]</a></span>
784
784
+
</td></tr>
785
785
+
786
786
+
<tr class="t-dsc">
787
787
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ios/rdstate.html" title="cpp/io/basic ios/rdstate"> <span class="t-lines"><span>rdstate</span></span></a></div></div>
788
788
+
</td>
789
789
+
<td> returns state flags <br /> <span class="t-mark">(public member function of <code>std::basic_ios<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ios/dsc_rdstate&action=edit">[edit]</a></span>
790
790
+
</td></tr>
791
791
+
792
792
+
<tr class="t-dsc">
793
793
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ios/setstate.html" title="cpp/io/basic ios/setstate"> <span class="t-lines"><span>setstate</span></span></a></div></div>
794
794
+
</td>
795
795
+
<td> sets state flags <br /> <span class="t-mark">(public member function of <code>std::basic_ios<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ios/dsc_setstate&action=edit">[edit]</a></span>
796
796
+
</td></tr>
797
797
+
798
798
+
<tr class="t-dsc">
799
799
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ios/clear.html" title="cpp/io/basic ios/clear"> <span class="t-lines"><span>clear</span></span></a></div></div>
800
800
+
</td>
801
801
+
<td> modifies state flags <br /> <span class="t-mark">(public member function of <code>std::basic_ios<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ios/dsc_clear&action=edit">[edit]</a></span>
802
802
+
</td></tr>
803
803
+
804
804
+
805
805
+
<tr>
806
806
+
<td colspan="2"> <h5> <span class="mw-headline" id="Formatting"> Formatting </span></h5>
807
807
+
</td></tr>
808
808
+
809
809
+
<tr class="t-dsc">
810
810
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ios/copyfmt.html" title="cpp/io/basic ios/copyfmt"> <span class="t-lines"><span>copyfmt</span></span></a></div></div>
811
811
+
</td>
812
812
+
<td> copies formatting information <br /> <span class="t-mark">(public member function of <code>std::basic_ios<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ios/dsc_copyfmt&action=edit">[edit]</a></span>
813
813
+
</td></tr>
814
814
+
815
815
+
<tr class="t-dsc">
816
816
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ios/fill.html" title="cpp/io/basic ios/fill"> <span class="t-lines"><span>fill</span></span></a></div></div>
817
817
+
</td>
818
818
+
<td> manages the fill character <br /> <span class="t-mark">(public member function of <code>std::basic_ios<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ios/dsc_fill&action=edit">[edit]</a></span>
819
819
+
</td></tr>
820
820
+
821
821
+
822
822
+
<tr>
823
823
+
<td colspan="2"> <h5> <span class="mw-headline" id="Miscellaneous_2"> Miscellaneous </span></h5>
824
824
+
</td></tr>
825
825
+
826
826
+
<tr class="t-dsc">
827
827
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ios/exceptions.html" title="cpp/io/basic ios/exceptions"> <span class="t-lines"><span>exceptions</span></span></a></div></div>
828
828
+
</td>
829
829
+
<td> manages exception mask <br /> <span class="t-mark">(public member function of <code>std::basic_ios<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ios/dsc_exceptions&action=edit">[edit]</a></span>
830
830
+
</td></tr>
831
831
+
832
832
+
<tr class="t-dsc">
833
833
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ios/imbue.html" title="cpp/io/basic ios/imbue"> <span class="t-lines"><span>imbue</span></span></a></div></div>
834
834
+
</td>
835
835
+
<td> sets the locale <br /> <span class="t-mark">(public member function of <code>std::basic_ios<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ios/dsc_imbue&action=edit">[edit]</a></span>
836
836
+
</td></tr>
837
837
+
838
838
+
<tr class="t-dsc">
839
839
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ios/rdbuf.html" title="cpp/io/basic ios/rdbuf"> <span class="t-lines"><span>rdbuf</span></span></a></div></div>
840
840
+
</td>
841
841
+
<td> manages associated stream buffer <br /> <span class="t-mark">(public member function of <code>std::basic_ios<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ios/dsc_rdbuf&action=edit">[edit]</a></span>
842
842
+
</td></tr>
843
843
+
844
844
+
<tr class="t-dsc">
845
845
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ios/tie.html" title="cpp/io/basic ios/tie"> <span class="t-lines"><span>tie</span></span></a></div></div>
846
846
+
</td>
847
847
+
<td> manages tied stream <br /> <span class="t-mark">(public member function of <code>std::basic_ios<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ios/dsc_tie&action=edit">[edit]</a></span>
848
848
+
</td></tr>
849
849
+
850
850
+
<tr class="t-dsc">
851
851
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ios/narrow.html" title="cpp/io/basic ios/narrow"> <span class="t-lines"><span>narrow</span></span></a></div></div>
852
852
+
</td>
853
853
+
<td> narrows characters <br /> <span class="t-mark">(public member function of <code>std::basic_ios<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ios/dsc_narrow&action=edit">[edit]</a></span>
854
854
+
</td></tr>
855
855
+
856
856
+
<tr class="t-dsc">
857
857
+
<td> <div class="t-dsc-member-div"><div><a href="basic_ios/widen.html" title="cpp/io/basic ios/widen"> <span class="t-lines"><span>widen</span></span></a></div></div>
858
858
+
</td>
859
859
+
<td> widens characters <br /> <span class="t-mark">(public member function of <code>std::basic_ios<CharT,Traits></code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/basic_ios/dsc_widen&action=edit">[edit]</a></span>
860
860
+
</td></tr>
861
861
+
</table>
862
862
+
</div>
863
863
+
<div class="t-inherited">
864
864
+
<h2> <span class="mw-headline" id="Inherited_from_std::ios_base">Inherited from <a href="ios_base.html" title="cpp/io/ios base"> <span style="font-size:0.7em; line-height:130%">std::</span>ios_base</a> </span></h2>
865
865
+
<h3> <span class="mw-headline" id="Member_functions_4">Member functions</span></h3>
866
866
+
<table class="t-dsc-begin">
867
867
+
868
868
+
869
869
+
<tr>
870
870
+
<td colspan="2"> <h5> <span class="mw-headline" id="Formatting_2"> Formatting </span></h5>
871
871
+
</td></tr>
872
872
+
873
873
+
<tr class="t-dsc">
874
874
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/flags.html" title="cpp/io/ios base/flags"> <span class="t-lines"><span>flags</span></span></a></div></div>
875
875
+
</td>
876
876
+
<td> manages format flags <br /> <span class="t-mark">(public member function of <code>std::ios_base</code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_flags&action=edit">[edit]</a></span>
877
877
+
</td></tr>
878
878
+
879
879
+
<tr class="t-dsc">
880
880
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/setf.html" title="cpp/io/ios base/setf"> <span class="t-lines"><span>setf</span></span></a></div></div>
881
881
+
</td>
882
882
+
<td> sets specific format flag <br /> <span class="t-mark">(public member function of <code>std::ios_base</code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_setf&action=edit">[edit]</a></span>
883
883
+
</td></tr>
884
884
+
885
885
+
<tr class="t-dsc">
886
886
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/unsetf.html" title="cpp/io/ios base/unsetf"> <span class="t-lines"><span>unsetf</span></span></a></div></div>
887
887
+
</td>
888
888
+
<td> clears specific format flag <br /> <span class="t-mark">(public member function of <code>std::ios_base</code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_unsetf&action=edit">[edit]</a></span>
889
889
+
</td></tr>
890
890
+
891
891
+
<tr class="t-dsc">
892
892
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/precision.html" title="cpp/io/ios base/precision"> <span class="t-lines"><span>precision</span></span></a></div></div>
893
893
+
</td>
894
894
+
<td> manages decimal precision of floating point operations <br /> <span class="t-mark">(public member function of <code>std::ios_base</code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_precision&action=edit">[edit]</a></span>
895
895
+
</td></tr>
896
896
+
897
897
+
<tr class="t-dsc">
898
898
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/width.html" title="cpp/io/ios base/width"> <span class="t-lines"><span>width</span></span></a></div></div>
899
899
+
</td>
900
900
+
<td> manages field width <br /> <span class="t-mark">(public member function of <code>std::ios_base</code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_width&action=edit">[edit]</a></span>
901
901
+
</td></tr>
902
902
+
903
903
+
904
904
+
<tr>
905
905
+
<td colspan="2"> <h5> <span class="mw-headline" id="Locales"> Locales </span></h5>
906
906
+
</td></tr>
907
907
+
908
908
+
<tr class="t-dsc">
909
909
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/imbue.html" title="cpp/io/ios base/imbue"> <span class="t-lines"><span>imbue</span></span></a></div></div>
910
910
+
</td>
911
911
+
<td> sets locale <br /> <span class="t-mark">(public member function of <code>std::ios_base</code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_imbue&action=edit">[edit]</a></span>
912
912
+
</td></tr>
913
913
+
914
914
+
<tr class="t-dsc">
915
915
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/getloc.html" title="cpp/io/ios base/getloc"> <span class="t-lines"><span>getloc</span></span></a></div></div>
916
916
+
</td>
917
917
+
<td> returns current locale <br /> <span class="t-mark">(public member function of <code>std::ios_base</code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_getloc&action=edit">[edit]</a></span>
918
918
+
</td></tr>
919
919
+
920
920
+
921
921
+
<tr>
922
922
+
<td colspan="2"> <h5> <span class="mw-headline" id="Internal_extensible_array"> Internal extensible array </span></h5>
923
923
+
</td></tr>
924
924
+
925
925
+
<tr class="t-dsc">
926
926
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/xalloc.html" title="cpp/io/ios base/xalloc"> <span class="t-lines"><span>xalloc</span></span></a></div><div><span class="t-lines"><span><span class="t-cmark">[static]</span></span></span></div></div>
927
927
+
</td>
928
928
+
<td> returns a program-wide unique integer that is safe to use as index to <a href="ios_base/pword.html" title="cpp/io/ios base/pword"><tt>pword()</tt></a> and <a href="ios_base/iword.html" title="cpp/io/ios base/iword"><tt>iword()</tt></a> <br /> <span class="t-mark">(public static member function of <code>std::ios_base</code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_xalloc&action=edit">[edit]</a></span>
929
929
+
</td></tr>
930
930
+
931
931
+
<tr class="t-dsc">
932
932
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/iword.html" title="cpp/io/ios base/iword"> <span class="t-lines"><span>iword</span></span></a></div></div>
933
933
+
</td>
934
934
+
<td> resizes the private storage if necessary and access to the <span class="mw-geshi cpp source-cpp"><span class="kw4">long</span></span> element at the given index <br /> <span class="t-mark">(public member function of <code>std::ios_base</code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_iword&action=edit">[edit]</a></span>
935
935
+
</td></tr>
936
936
+
937
937
+
<tr class="t-dsc">
938
938
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/pword.html" title="cpp/io/ios base/pword"> <span class="t-lines"><span>pword</span></span></a></div></div>
939
939
+
</td>
940
940
+
<td> resizes the private storage if necessary and access to the <span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span></span> element at the given index <br /> <span class="t-mark">(public member function of <code>std::ios_base</code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_pword&action=edit">[edit]</a></span>
941
941
+
</td></tr>
942
942
+
943
943
+
944
944
+
<tr>
945
945
+
<td colspan="2"> <h5> <span class="mw-headline" id="Miscellaneous_3"> Miscellaneous </span></h5>
946
946
+
</td></tr>
947
947
+
948
948
+
<tr class="t-dsc">
949
949
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/register_callback.html" title="cpp/io/ios base/register callback"> <span class="t-lines"><span>register_callback</span></span></a></div></div>
950
950
+
</td>
951
951
+
<td> registers event callback function <br /> <span class="t-mark">(public member function of <code>std::ios_base</code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_register_callback&action=edit">[edit]</a></span>
952
952
+
</td></tr>
953
953
+
954
954
+
<tr class="t-dsc">
955
955
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/sync_with_stdio.html" title="cpp/io/ios base/sync with stdio"> <span class="t-lines"><span>sync_with_stdio</span></span></a></div><div><span class="t-lines"><span><span class="t-cmark">[static]</span></span></span></div></div>
956
956
+
</td>
957
957
+
<td> sets whether C++ and C I/O libraries are interoperable <br /> <span class="t-mark">(public static member function of <code>std::ios_base</code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_sync_with_stdio&action=edit">[edit]</a></span>
958
958
+
</td></tr>
959
959
+
960
960
+
961
961
+
<tr>
962
962
+
<td colspan="2"> <h5> <span class="mw-headline" id="Member_classes_2"> Member classes </span></h5>
963
963
+
</td></tr>
964
964
+
965
965
+
<tr class="t-dsc">
966
966
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/failure.html" title="cpp/io/ios base/failure"> <span class="t-lines"><span>failure</span></span></a></div></div>
967
967
+
</td>
968
968
+
<td> stream exception <br /> <span class="t-mark">(public member class of <code>std::ios_base</code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_failure&action=edit">[edit]</a></span>
969
969
+
</td></tr>
970
970
+
971
971
+
<tr class="t-dsc">
972
972
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/Init.html" title="cpp/io/ios base/Init"> <span class="t-lines"><span>Init</span></span></a></div></div>
973
973
+
</td>
974
974
+
<td> initializes standard stream objects <br /> <span class="t-mark">(public member class of <code>std::ios_base</code>)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_Init&action=edit">[edit]</a></span>
975
975
+
</td></tr>
976
976
+
</table>
977
977
+
<table class="t-dsc-begin">
978
978
+
979
979
+
<tr>
980
980
+
<td colspan="2"> <h3> <span class="mw-headline" id="Member_types_and_constants"> Member types and constants</span></h3>
981
981
+
</td></tr>
982
982
+
983
983
+
<tr class="t-dsc-hitem">
984
984
+
<td> Type
985
985
+
</td>
986
986
+
<td> Explanation
987
987
+
</td></tr>
988
988
+
989
989
+
990
990
+
<tr class="t-dsc">
991
991
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"> <span class="t-lines"><span>openmode</span></span></a></div></div>
992
992
+
</td>
993
993
+
<td> stream open mode type
994
994
+
<p>The following constants are also defined:
995
995
+
</p>
996
996
+
<table class="t-dsc-begin">
997
997
+
998
998
+
<tr class="t-dsc-hitem">
999
999
+
<td> Constant
1000
1000
+
</td>
1001
1001
+
<td> Explanation<span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_openmode&action=edit">[edit]</a></span>
1002
1002
+
</td></tr>
1003
1003
+
1004
1004
+
1005
1005
+
<tr class="t-dsc">
1006
1006
+
<td> <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>app</tt></a>
1007
1007
+
</td>
1008
1008
+
<td> seek to the end of stream before each write<span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_openmode&action=edit">[edit]</a></span>
1009
1009
+
</td></tr>
1010
1010
+
1011
1011
+
1012
1012
+
<tr class="t-dsc">
1013
1013
+
<td> <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>binary</tt></a>
1014
1014
+
</td>
1015
1015
+
<td> open in <a href="c/FILE.html#Binary_and_text_modes" title="cpp/io/c/FILE">binary mode</a><span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_openmode&action=edit">[edit]</a></span>
1016
1016
+
</td></tr>
1017
1017
+
1018
1018
+
1019
1019
+
<tr class="t-dsc">
1020
1020
+
<td> <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>in</tt></a>
1021
1021
+
</td>
1022
1022
+
<td> open for reading<span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_openmode&action=edit">[edit]</a></span>
1023
1023
+
</td></tr>
1024
1024
+
1025
1025
+
1026
1026
+
<tr class="t-dsc">
1027
1027
+
<td> <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>out</tt></a>
1028
1028
+
</td>
1029
1029
+
<td> open for writing<span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_openmode&action=edit">[edit]</a></span>
1030
1030
+
</td></tr>
1031
1031
+
1032
1032
+
1033
1033
+
<tr class="t-dsc">
1034
1034
+
<td> <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>trunc</tt></a>
1035
1035
+
</td>
1036
1036
+
<td> discard the contents of the stream when opening<span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_openmode&action=edit">[edit]</a></span>
1037
1037
+
</td></tr>
1038
1038
+
1039
1039
+
1040
1040
+
<tr class="t-dsc">
1041
1041
+
<td> <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>ate</tt></a>
1042
1042
+
</td>
1043
1043
+
<td> seek to the end of stream immediately after open<span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_openmode&action=edit">[edit]</a></span>
1044
1044
+
</td></tr>
1045
1045
+
1046
1046
+
1047
1047
+
<tr class="t-dsc">
1048
1048
+
<td> <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>noreplace</tt></a> <span class="t-mark-rev t-since-cxx23">(C++23)</span>
1049
1049
+
</td>
1050
1050
+
<td> open in exclusive mode<span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_openmode&action=edit">[edit]</a></span>
1051
1051
+
</td></tr>
1052
1052
+
1053
1053
+
</table> <br /> <span class="t-mark">(typedef)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_openmode&action=edit">[edit]</a></span>
1054
1054
+
</td></tr>
1055
1055
+
1056
1056
+
<tr class="t-dsc">
1057
1057
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"> <span class="t-lines"><span>fmtflags</span></span></a></div></div>
1058
1058
+
</td>
1059
1059
+
<td> formatting flags type
1060
1060
+
<p>The following constants are also defined:
1061
1061
+
</p>
1062
1062
+
<table class="t-dsc-begin">
1063
1063
+
1064
1064
+
<tr class="t-dsc-hitem">
1065
1065
+
<td> Constant
1066
1066
+
</td>
1067
1067
+
<td> Explanation<span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1068
1068
+
</td></tr>
1069
1069
+
1070
1070
+
1071
1071
+
<tr class="t-dsc">
1072
1072
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>dec</tt></a>
1073
1073
+
</td>
1074
1074
+
<td> use decimal base for integer I/O: see <span class="t-lc"><a href="manip/hex.html" title="cpp/io/manip/hex">std::dec</a></span><span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1075
1075
+
</td></tr>
1076
1076
+
1077
1077
+
1078
1078
+
<tr class="t-dsc">
1079
1079
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>oct</tt></a>
1080
1080
+
</td>
1081
1081
+
<td> use octal base for integer I/O: see <span class="t-lc"><a href="manip/hex.html" title="cpp/io/manip/hex">std::oct</a></span><span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1082
1082
+
</td></tr>
1083
1083
+
1084
1084
+
1085
1085
+
<tr class="t-dsc">
1086
1086
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>hex</tt></a>
1087
1087
+
</td>
1088
1088
+
<td> use hexadecimal base for integer I/O: see <span class="t-lc"><a href="manip/hex.html" title="cpp/io/manip/hex">std::hex</a></span><span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1089
1089
+
</td></tr>
1090
1090
+
1091
1091
+
1092
1092
+
<tr class="t-dsc">
1093
1093
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>basefield</tt></a>
1094
1094
+
</td>
1095
1095
+
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">dec <span class="sy3">|</span> oct <span class="sy3">|</span> hex</span></span>. Useful for masking operations<span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1096
1096
+
</td></tr>
1097
1097
+
1098
1098
+
1099
1099
+
<tr class="t-dsc">
1100
1100
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>left</tt></a>
1101
1101
+
</td>
1102
1102
+
<td> left adjustment (adds fill characters to the right): see <span class="t-lc"><a href="manip/left.html" title="cpp/io/manip/left">std::left</a></span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1103
1103
+
</td></tr>
1104
1104
+
1105
1105
+
1106
1106
+
<tr class="t-dsc">
1107
1107
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>right</tt></a>
1108
1108
+
</td>
1109
1109
+
<td> right adjustment (adds fill characters to the left): see <span class="t-lc"><a href="manip/left.html" title="cpp/io/manip/left">std::right</a></span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1110
1110
+
</td></tr>
1111
1111
+
1112
1112
+
1113
1113
+
<tr class="t-dsc">
1114
1114
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>internal</tt></a>
1115
1115
+
</td>
1116
1116
+
<td> internal adjustment (adds fill characters to the internal designated point): see <span class="t-lc"><a href="manip/left.html" title="cpp/io/manip/left">std::internal</a></span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1117
1117
+
</td></tr>
1118
1118
+
1119
1119
+
1120
1120
+
<tr class="t-dsc">
1121
1121
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>adjustfield</tt></a>
1122
1122
+
</td>
1123
1123
+
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">left <span class="sy3">|</span> right <span class="sy3">|</span> internal</span></span>. Useful for masking operations <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1124
1124
+
</td></tr>
1125
1125
+
1126
1126
+
1127
1127
+
<tr class="t-dsc">
1128
1128
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>scientific</tt></a>
1129
1129
+
</td>
1130
1130
+
<td> generate floating point types using scientific notation, or hex notation if combined with <span class="t-c"><span class="mw-geshi cpp source-cpp">fixed</span></span>: see <span class="t-lc"><a href="manip/fixed.html" title="cpp/io/manip/fixed">std::scientific</a></span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1131
1131
+
</td></tr>
1132
1132
+
1133
1133
+
1134
1134
+
<tr class="t-dsc">
1135
1135
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>fixed</tt></a>
1136
1136
+
</td>
1137
1137
+
<td> generate floating point types using fixed notation, or hex notation if combined with <span class="t-c"><span class="mw-geshi cpp source-cpp">scientific</span></span>: see <span class="t-lc"><a href="manip/fixed.html" title="cpp/io/manip/fixed">std::fixed</a></span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1138
1138
+
</td></tr>
1139
1139
+
1140
1140
+
1141
1141
+
<tr class="t-dsc">
1142
1142
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>floatfield</tt></a>
1143
1143
+
</td>
1144
1144
+
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">scientific <span class="sy3">|</span> fixed</span></span>. Useful for masking operations <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1145
1145
+
</td></tr>
1146
1146
+
1147
1147
+
1148
1148
+
<tr class="t-dsc">
1149
1149
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>boolalpha</tt></a>
1150
1150
+
</td>
1151
1151
+
<td> insert and extract <span class="mw-geshi cpp source-cpp"><span class="kw4">bool</span></span> type in alphanumeric format: see <span class="t-lc"><a href="manip/boolalpha.html" title="cpp/io/manip/boolalpha">std::boolalpha</a></span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1152
1152
+
</td></tr>
1153
1153
+
1154
1154
+
1155
1155
+
<tr class="t-dsc">
1156
1156
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>showbase</tt></a>
1157
1157
+
</td>
1158
1158
+
<td> generate a prefix indicating the numeric base for integer output, require the currency indicator in monetary I/O: see <span class="t-lc"><a href="manip/showbase.html" title="cpp/io/manip/showbase">std::showbase</a></span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1159
1159
+
</td></tr>
1160
1160
+
1161
1161
+
1162
1162
+
<tr class="t-dsc">
1163
1163
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>showpoint</tt></a>
1164
1164
+
</td>
1165
1165
+
<td> generate a decimal-point character unconditionally for floating-point number output: see <span class="t-lc"><a href="manip/showpoint.html" title="cpp/io/manip/showpoint">std::showpoint</a></span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1166
1166
+
</td></tr>
1167
1167
+
1168
1168
+
1169
1169
+
<tr class="t-dsc">
1170
1170
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>showpos</tt></a>
1171
1171
+
</td>
1172
1172
+
<td> generate a <span class="mw-geshi cpp source-cpp"><span class="sy2">+</span></span> character for non-negative numeric output: see <span class="t-lc"><a href="manip/showpos.html" title="cpp/io/manip/showpos">std::showpos</a></span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1173
1173
+
</td></tr>
1174
1174
+
1175
1175
+
1176
1176
+
<tr class="t-dsc">
1177
1177
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>skipws</tt></a>
1178
1178
+
</td>
1179
1179
+
<td> skip leading whitespace before certain input operations: see <span class="t-lc"><a href="manip/skipws.html" title="cpp/io/manip/skipws">std::skipws</a></span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1180
1180
+
</td></tr>
1181
1181
+
1182
1182
+
1183
1183
+
<tr class="t-dsc">
1184
1184
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>unitbuf</tt></a>
1185
1185
+
</td>
1186
1186
+
<td> flush the output after each output operation: see <span class="t-lc"><a href="manip/unitbuf.html" title="cpp/io/manip/unitbuf">std::unitbuf</a></span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1187
1187
+
</td></tr>
1188
1188
+
1189
1189
+
1190
1190
+
<tr class="t-dsc">
1191
1191
+
<td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>uppercase</tt></a>
1192
1192
+
</td>
1193
1193
+
<td> replace certain lowercase letters with their uppercase<br />equivalents in certain output operations: see <span class="t-lc"><a href="manip/uppercase.html" title="cpp/io/manip/uppercase">std::uppercase</a></span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1194
1194
+
</td></tr>
1195
1195
+
1196
1196
+
</table> <br /> <span class="t-mark">(typedef)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_fmtflags&action=edit">[edit]</a></span>
1197
1197
+
</td></tr>
1198
1198
+
1199
1199
+
<tr class="t-dsc">
1200
1200
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/iostate.html" title="cpp/io/ios base/iostate"> <span class="t-lines"><span>iostate</span></span></a></div></div>
1201
1201
+
</td>
1202
1202
+
<td> state of the stream type
1203
1203
+
<p>The following constants are also defined:
1204
1204
+
</p>
1205
1205
+
<table class="t-dsc-begin">
1206
1206
+
1207
1207
+
<tr class="t-dsc-hitem">
1208
1208
+
<td> Constant
1209
1209
+
</td>
1210
1210
+
<td> Explanation<span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_iostate&action=edit">[edit]</a></span>
1211
1211
+
</td></tr>
1212
1212
+
1213
1213
+
1214
1214
+
<tr class="t-dsc">
1215
1215
+
<td> <a href="ios_base/iostate.html" title="cpp/io/ios base/iostate"><tt>goodbit</tt></a>
1216
1216
+
</td>
1217
1217
+
<td> no error<span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_iostate&action=edit">[edit]</a></span>
1218
1218
+
</td></tr>
1219
1219
+
1220
1220
+
1221
1221
+
<tr class="t-dsc">
1222
1222
+
<td> <a href="ios_base/iostate.html" title="cpp/io/ios base/iostate"><tt>badbit</tt></a>
1223
1223
+
</td>
1224
1224
+
<td> irrecoverable stream error<span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_iostate&action=edit">[edit]</a></span>
1225
1225
+
</td></tr>
1226
1226
+
1227
1227
+
1228
1228
+
<tr class="t-dsc">
1229
1229
+
<td> <a href="ios_base/iostate.html" title="cpp/io/ios base/iostate"><tt>failbit</tt></a>
1230
1230
+
</td>
1231
1231
+
<td> input/output operation failed (formatting or extraction error)<span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_iostate&action=edit">[edit]</a></span>
1232
1232
+
</td></tr>
1233
1233
+
1234
1234
+
1235
1235
+
<tr class="t-dsc">
1236
1236
+
<td> <a href="ios_base/iostate.html" title="cpp/io/ios base/iostate"><tt>eofbit</tt></a>
1237
1237
+
</td>
1238
1238
+
<td> associated input sequence has reached end-of-file<span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_iostate&action=edit">[edit]</a></span>
1239
1239
+
</td></tr>
1240
1240
+
1241
1241
+
</table> <br /> <span class="t-mark">(typedef)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_iostate&action=edit">[edit]</a></span>
1242
1242
+
</td></tr>
1243
1243
+
1244
1244
+
<tr class="t-dsc">
1245
1245
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/seekdir.html" title="cpp/io/ios base/seekdir"> <span class="t-lines"><span>seekdir</span></span></a></div></div>
1246
1246
+
</td>
1247
1247
+
<td> seeking direction type
1248
1248
+
<p>The following constants are also defined:
1249
1249
+
</p>
1250
1250
+
<table class="t-dsc-begin">
1251
1251
+
1252
1252
+
<tr class="t-dsc-hitem">
1253
1253
+
<td> Constant
1254
1254
+
</td>
1255
1255
+
<td> Explanation<span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_seekdir&action=edit">[edit]</a></span>
1256
1256
+
</td></tr>
1257
1257
+
1258
1258
+
1259
1259
+
<tr class="t-dsc">
1260
1260
+
<td> <a href="ios_base/seekdir.html" title="cpp/io/ios base/seekdir"><tt>beg</tt></a>
1261
1261
+
</td>
1262
1262
+
<td> the beginning of a stream <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_seekdir&action=edit">[edit]</a></span>
1263
1263
+
</td></tr>
1264
1264
+
1265
1265
+
1266
1266
+
<tr class="t-dsc">
1267
1267
+
<td> <a href="ios_base/seekdir.html" title="cpp/io/ios base/seekdir"><tt>end</tt></a>
1268
1268
+
</td>
1269
1269
+
<td> the ending of a stream <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_seekdir&action=edit">[edit]</a></span>
1270
1270
+
</td></tr>
1271
1271
+
1272
1272
+
1273
1273
+
<tr class="t-dsc">
1274
1274
+
<td> <a href="ios_base/seekdir.html" title="cpp/io/ios base/seekdir"><tt>cur</tt></a>
1275
1275
+
</td>
1276
1276
+
<td> the current position of stream position indicator <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_seekdir&action=edit">[edit]</a></span>
1277
1277
+
</td></tr>
1278
1278
+
1279
1279
+
</table> <br /> <span class="t-mark">(typedef)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_seekdir&action=edit">[edit]</a></span>
1280
1280
+
</td></tr>
1281
1281
+
1282
1282
+
<tr class="t-dsc">
1283
1283
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/event.html" title="cpp/io/ios base/event"> <span class="t-lines"><span>event</span></span></a></div></div>
1284
1284
+
</td>
1285
1285
+
<td> specifies event type <br /> <span class="t-mark">(enum)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_event&action=edit">[edit]</a></span>
1286
1286
+
</td></tr>
1287
1287
+
1288
1288
+
<tr class="t-dsc">
1289
1289
+
<td> <div class="t-dsc-member-div"><div><a href="ios_base/event_callback.html" title="cpp/io/ios base/event callback"> <span class="t-lines"><span>event_callback</span></span></a></div></div>
1290
1290
+
</td>
1291
1291
+
<td> callback function type <br /> <span class="t-mark">(typedef)</span> <span class="editsection noprint plainlinks" title="Edit this template"><a rel="nofollow" class="external text" href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/ios_base/dsc_event_callback&action=edit">[edit]</a></span>
1292
1292
+
</td></tr>
1293
1293
+
</table>
1294
1294
+
</div>
1295
1295
+
<h3><span class="editsection">[<a href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&action=edit&section=3" title="Edit section: Notes">edit</a>]</span> <span class="mw-headline" id="Notes">Notes</span></h3>
1296
1296
+
<table class="wikitable ftm-begin ftm-has-value">
1297
1297
+
1298
1298
+
<tr>
1299
1299
+
<th><a href="../utility/feature_test.html" title="cpp/utility/feature test">Feature-test</a> macro</th>
1300
1300
+
<th>Value</th>
1301
1301
+
<th><span title="Standard in which the feature is introduced">Std</span></th>
1302
1302
+
<th>Feature
1303
1303
+
</th></tr>
1304
1304
+
<tr>
1305
1305
+
<td><a href="../feature_test.html#cpp_lib_fstream_native_handle" title="cpp/feature test"><code>__cpp_lib_fstream_native_handle</code></a></td>
1306
1306
+
<td><span class="mw-geshi cpp source-cpp"><span class="nu0">202306L</span></span></td>
1307
1307
+
<td><span class="t-mark">(C++26)</span></td>
1308
1308
+
<td>native handles support
1309
1309
+
</td></tr></table>
1310
1310
+
<h3><span class="editsection">[<a href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&action=edit&section=4" title="Edit section: Example">edit</a>]</span> <span class="mw-headline" id="Example">Example</span></h3>
1311
1311
+
<div class="t-example"><div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">Run this code</div></div>
1312
1312
+
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#include <fstream></span>
1313
1313
+
<span class="co2">#include <iostream></span>
1314
1314
+
<span class="co2">#include <string></span>
1315
1315
+
 
1316
1316
+
<span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span>
1317
1317
+
<span class="br0">{</span>
1318
1318
+
<a href="../string/basic_string.html"><span class="kw1233">std::<span class="me2">string</span></span></a> filename <span class="sy1">=</span> <span class="st0">"Test.b"</span><span class="sy4">;</span>
1319
1319
+
 
1320
1320
+
<span class="co1">// prepare a file to read</span>
1321
1321
+
<span class="kw4">double</span> d <span class="sy1">=</span> <span class="nu16">3.14</span><span class="sy4">;</span>
1322
1322
+
<a href="basic_ofstream.html"><span class="kw1735">std::<span class="me2">ofstream</span></span></a><span class="br0">(</span>filename, std<span class="sy4">::</span><span class="me2">ios</span><span class="sy4">::</span><span class="me2">binary</span><span class="br0">)</span>
1323
1323
+
.<span class="me1">write</span><span class="br0">(</span><span class="kw1">reinterpret_cast</span><span class="sy1"><</span><span class="kw4">char</span><span class="sy2">*</span><span class="sy1">></span><span class="br0">(</span><span class="sy3">&</span>d<span class="br0">)</span>, sizeof d<span class="br0">)</span> <span class="sy1"><<</span> <span class="nu0">123</span> <span class="sy1"><<</span> <span class="st0">"abc"</span><span class="sy4">;</span>
1324
1324
+
 
1325
1325
+
<span class="co1">// open file for reading</span>
1326
1326
+
std<span class="sy4">::</span><span class="me2">ifstream</span> istrm<span class="br0">(</span>filename, std<span class="sy4">::</span><span class="me2">ios</span><span class="sy4">::</span><span class="me2">binary</span><span class="br0">)</span><span class="sy4">;</span>
1327
1327
+
<span class="kw1">if</span> <span class="br0">(</span><span class="sy3">!</span>istrm.<span class="me1">is_open</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span>
1328
1328
+
<a href="cout.html"><span class="kw1759">std::<span class="me2">cout</span></span></a> <span class="sy1"><<</span> <span class="st0">"failed to open "</span> <span class="sy1"><<</span> filename <span class="sy1"><<</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
1329
1329
+
<span class="kw1">else</span>
1330
1330
+
<span class="br0">{</span>
1331
1331
+
<span class="kw4">double</span> d<span class="sy4">;</span>
1332
1332
+
istrm.<span class="me1">read</span><span class="br0">(</span><span class="kw1">reinterpret_cast</span><span class="sy1"><</span><span class="kw4">char</span><span class="sy2">*</span><span class="sy1">></span><span class="br0">(</span><span class="sy3">&</span>d<span class="br0">)</span>, sizeof d<span class="br0">)</span><span class="sy4">;</span> <span class="co1">// binary input</span>
1333
1333
+
<span class="kw4">int</span> n<span class="sy4">;</span>
1334
1334
+
<a href="../string/basic_string.html"><span class="kw1233">std::<span class="me2">string</span></span></a> s<span class="sy4">;</span>
1335
1335
+
<span class="kw1">if</span> <span class="br0">(</span>istrm <span class="sy1">>></span> n <span class="sy1">>></span> s<span class="br0">)</span> <span class="co1">// text input</span>
1336
1336
+
<a href="cout.html"><span class="kw1759">std::<span class="me2">cout</span></span></a> <span class="sy1"><<</span> <span class="st0">"read back from file: "</span> <span class="sy1"><<</span> d <span class="sy1"><<</span> <span class="st0">' '</span> <span class="sy1"><<</span> n <span class="sy1"><<</span> <span class="st0">' '</span> <span class="sy1"><<</span> s <span class="sy1"><<</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
1337
1337
+
<span class="br0">}</span>
1338
1338
+
<span class="br0">}</span></pre></div></div>
1339
1339
+
<p>Output:
1340
1340
+
</p>
1341
1341
+
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="text source-text"><pre class="de1">read back from file: 3.14 123 abc</pre></div></div>
1342
1342
+
</div>
1343
1343
+
1344
1344
+
<!--
1345
1345
+
NewPP limit report
1346
1346
+
Preprocessor visited node count: 17503/1000000
1347
1347
+
Preprocessor generated node count: 16854/1000000
1348
1348
+
Post‐expand include size: 636886/2097152 bytes
1349
1349
+
Template argument size: 178179/2097152 bytes
1350
1350
+
Highest expansion depth: 35/40
1351
1351
+
Expensive parser function count: 0/100
1352
1352
+
-->
1353
1353
+
1354
1354
+
<!-- Saved in parser cache with key mwiki1-mwiki_en_:pcache:idhash:494-0!*!0!!en!2!* and timestamp 20231109085046 -->
1355
1355
+
</div> <!-- /bodycontent -->
1356
1356
+
<!-- printfooter -->
1357
1357
+
<div class="printfooter">
1358
1358
+
Retrieved from "<a href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&oldid=158179">https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&oldid=158179</a>" </div>
1359
1359
+
<!-- /printfooter -->
1360
1360
+
<!-- catlinks -->
1361
1361
+
<div id='catlinks' class='catlinks catlinks-allhidden'></div> <!-- /catlinks -->
1362
1362
+
<div class="visualClear"></div>
1363
1363
+
<!-- debughtml -->
1364
1364
+
<!-- /debughtml -->
1365
1365
+
</div>
1366
1366
+
<!-- /bodyContent -->
1367
1367
+
</div>
1368
1368
+
</div>
1369
1369
+
<!-- /content -->
1370
1370
+
<!-- footer -->
1371
1371
+
<div id="cpp-footer-base" class="noprint">
1372
1372
+
<div id="footer">
1373
1373
+
<div id="cpp-navigation">
1374
1374
+
<h5>Navigation</h5>
1375
1375
+
<ul>
1376
1376
+
<li id="n-Support-us"><a href="http://www.cppreference.com/support" rel="nofollow">Support us</a></li><li id="n-recentchanges"><a href="https://en.cppreference.com/w/Special:RecentChanges" title="A list of recent changes in the wiki [r]" accesskey="r">Recent changes</a></li><li id="n-FAQ"><a href="https://en.cppreference.com/w/Cppreference:FAQ">FAQ</a></li><li id="n-Offline-version"><a href="https://en.cppreference.com/w/Cppreference:Archives">Offline version</a></li> </ul>
1377
1377
+
</div>
1378
1378
+
<div id="cpp-toolbox">
1379
1379
+
<h5><span>Toolbox</span><a href="basic_ifstream.html#"></a></h5>
1380
1380
+
<ul>
1381
1381
+
<li id="t-whatlinkshere"><a href="https://en.cppreference.com/w/Special:WhatLinksHere/cpp/io/basic_ifstream" title="A list of all wiki pages that link here [j]" accesskey="j">What links here</a></li><li id="t-recentchangeslinked"><a href="https://en.cppreference.com/w/Special:RecentChangesLinked/cpp/io/basic_ifstream" title="Recent changes in pages linked from this page [k]" accesskey="k">Related changes</a></li><li id="t-upload"><a href="http://upload.cppreference.com/w/Special:Upload" title="Upload files [u]" accesskey="u">Upload file</a></li><li id="t-specialpages"><a href="https://en.cppreference.com/w/Special:SpecialPages" title="A list of all special pages [q]" accesskey="q">Special pages</a></li><li id="t-print"><a href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&printable=yes" rel="alternate" title="Printable version of this page [p]" accesskey="p">Printable version</a></li><li id="t-permalink"><a href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&oldid=158179" title="Permanent link to this revision of the page">Permanent link</a></li><li id="t-info"><a href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&action=info">Page information</a></li> </ul>
1382
1382
+
</div>
1383
1383
+
<div id="cpp-languages">
1384
1384
+
<div><ul><li>In other languages</li></ul></div>
1385
1385
+
<div><ul>
1386
1386
+
<li class="interwiki-de"><a href="http://de.cppreference.com/w/cpp/io/basic_ifstream" title="cpp/io/basic ifstream" lang="de" hreflang="de">Deutsch</a></li><li class="interwiki-es"><a href="http://es.cppreference.com/w/cpp/io/basic_ifstream" title="cpp/io/basic ifstream" lang="es" hreflang="es">Español</a></li><li class="interwiki-fr"><a href="http://fr.cppreference.com/w/cpp/io/basic_ifstream" title="cpp/io/basic ifstream" lang="fr" hreflang="fr">Français</a></li><li class="interwiki-it"><a href="http://it.cppreference.com/w/cpp/io/basic_ifstream" title="cpp/io/basic ifstream" lang="it" hreflang="it">Italiano</a></li><li class="interwiki-ja"><a href="http://ja.cppreference.com/w/cpp/io/basic_ifstream" title="cpp/io/basic ifstream" lang="ja" hreflang="ja">日本語</a></li><li class="interwiki-pt"><a href="http://pt.cppreference.com/w/cpp/io/basic_ifstream" title="cpp/io/basic ifstream" lang="pt" hreflang="pt">Português</a></li><li class="interwiki-ru"><a href="http://ru.cppreference.com/w/cpp/io/basic_ifstream" title="cpp/io/basic ifstream" lang="ru" hreflang="ru">Русский</a></li><li class="interwiki-zh"><a href="http://zh.cppreference.com/w/cpp/io/basic_ifstream" title="cpp/io/basic ifstream" lang="zh" hreflang="zh">中文</a></li> </ul></div>
1387
1387
+
</div>
1388
1388
+
<ul id="footer-info">
1389
1389
+
<li id="footer-info-lastmod"> This page was last modified on 7 September 2023, at 23:06.</li>
1390
1390
+
<li id="footer-info-viewcount">This page has been accessed 1,073,898 times.</li>
1391
1391
+
</ul>
1392
1392
+
<ul id="footer-places">
1393
1393
+
<li id="footer-places-privacy"><a href="https://en.cppreference.com/w/Cppreference:Privacy_policy" title="Cppreference:Privacy policy">Privacy policy</a></li>
1394
1394
+
<li id="footer-places-about"><a href="https://en.cppreference.com/w/Cppreference:About" title="Cppreference:About">About cppreference.com</a></li>
1395
1395
+
<li id="footer-places-disclaimer"><a href="https://en.cppreference.com/w/Cppreference:General_disclaimer" title="Cppreference:General disclaimer">Disclaimers</a></li>
1396
1396
+
</ul>
1397
1397
+
<ul id="footer-icons" class="noprint">
1398
1398
+
<li id="footer-poweredbyico">
1399
1399
+
<a href="https://www.mediawiki.org/"><img src="../../../mwiki/skins/common/images/poweredby_mediawiki_88x31.png" alt="Powered by MediaWiki" width="88" height="31" /></a> <a href="http://qbnz.com/highlighter/"><img src="../../../../upload.cppreference.com/mwiki/images/2/2b/powered_by_geshi_88x31.png" alt="Powered by GeSHi" height="31" width="88" /></a> <a href="http://www.tigertech.net/referral/cppreference.com"><img src="../../../../upload.cppreference.com/mwiki/images/9/94/powered_by_tigertech_88x31.png" alt="Hosted by Tiger Technologies" height="31" width="88" /></a> </li>
1400
1400
+
</ul>
1401
1401
+
<div style="clear:both">
1402
1402
+
</div>
1403
1403
+
</div>
1404
1404
+
</div>
1405
1405
+
<!-- /footer -->
1406
1406
+
<script>if(window.mw){
1407
1407
+
mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"});
1408
1408
+
}</script>
1409
1409
+
<script src="../../../mwiki/load.php%3Fdebug=false&lang=en&modules=skins.cppreference2&only=scripts&skin=cppreference2&*"></script>
1410
1410
+
<script>if(window.mw){
1411
1411
+
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.page.ready","mediawiki.searchSuggest","mediawiki.hidpi","ext.gadget.ColiruCompiler","ext.gadget.MathJax"], null, true);
1412
1412
+
}</script>
1413
1413
+
<script src="../../../mwiki/load.php%3Fdebug=false&lang=en&modules=site&only=scripts&skin=cppreference2&*"></script>
1414
1414
+
<script type="text/javascript">
1415
1415
+
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
1416
1416
+
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
1417
1417
+
</script>
1418
1418
+
<script type="text/javascript">
1419
1419
+
var _gaq = _gaq || [];
1420
1420
+
_gaq.push(['_setAccount', 'UA-2828341-1']);
1421
1421
+
_gaq.push(['_setDomainName', 'cppreference.com']);
1422
1422
+
_gaq.push(['_trackPageview']);
1423
1423
+
</script><!-- Served in 6.069 secs. -->
1424
1424
+
</body>
1425
1425
+
<!-- Cached 20231109085046 -->
1426
1426
+
</html>
build/a.out
This is a binary file and will not be displayed.
+214
src/indexer.cpp
···
1
1
+
#include "indexer.hpp"
2
2
+
#include "prelude.hpp"
3
3
+
#include <cctype>
4
4
+
#include <cstdlib>
5
5
+
6
6
+
fn filter_divs(std::string_view html) noexcept -> String
7
7
+
{
8
8
+
var buffer = String();
9
9
+
while (not html.empty()) {
10
10
+
if (html.front() == '<') [[unlikely]] {
11
11
+
while (html.front() != '>')
12
12
+
html.remove_prefix(1);
13
13
+
html.remove_prefix(1);
14
14
+
} else {
15
15
+
buffer += html.front();
16
16
+
html.remove_prefix(1);
17
17
+
}
18
18
+
}
19
19
+
20
20
+
return buffer;
21
21
+
}
22
22
+
23
23
+
fn to_words(std::string_view lines) noexcept -> Vector<String>
24
24
+
{
25
25
+
var buffer = Vector<String>();
26
26
+
let valid_char = [](Char ch) {
27
27
+
return (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z');
28
28
+
};
29
29
+
while (not lines.empty()) {
30
30
+
if (not valid_char(lines.front())) [[unlikely]] {
31
31
+
while (not lines.empty() &&
32
32
+
not valid_char(lines.front())) {
33
33
+
lines.remove_prefix(1);
34
34
+
}
35
35
+
} else {
36
36
+
var str = String();
37
37
+
while (valid_char(lines.front())) {
38
38
+
str += std::toupper(lines.front());
39
39
+
lines.remove_prefix(1);
40
40
+
}
41
41
+
buffer.push_back(str);
42
42
+
}
43
43
+
}
44
44
+
45
45
+
return buffer;
46
46
+
}
47
47
+
48
48
+
fn index_directory(std::filesystem::path dir) noexcept -> Vector<Document>
49
49
+
{
50
50
+
std::cout << "creating index of: " << dir << std::endl;
51
51
+
var documents = Vector<Document>();
52
52
+
for (let& dir_entry :
53
53
+
std::filesystem::recursive_directory_iterator(dir)) {
54
54
+
let path = dir_entry.path();
55
55
+
if (path.extension() != ".html")
56
56
+
continue;
57
57
+
let document = Document(path.native());
58
58
+
documents.push_back(document);
59
59
+
}
60
60
+
61
61
+
return documents;
62
62
+
}
63
63
+
64
64
+
fn count_query(Ref<const Vector<Document>> documents,
65
65
+
Ref<const String> query) noexcept
66
66
+
-> Vector<std::pair<String, F64>>
67
67
+
{
68
68
+
var matches = Vector<std::pair<String, F64>>();
69
69
+
for (let& document : documents) {
70
70
+
if (document.freqs.contains(query)) {
71
71
+
matches.push_back(
72
72
+
{document.filename, F64(document.freqs.at(query))});
73
73
+
}
74
74
+
}
75
75
+
return matches;
76
76
+
}
77
77
+
78
78
+
fn count_tfidf(Ref<const Vector<Document>> documents,
79
79
+
Ref<const String> query) noexcept
80
80
+
-> Vector<std::pair<String, F64>>
81
81
+
{
82
82
+
var matches = Vector<std::pair<String, F64>>();
83
83
+
var tf = F64();
84
84
+
var df = U64();
85
85
+
for (let& document : documents) {
86
86
+
if (document.freqs.contains(query)) {
87
87
+
tf = F64(document.freqs.at(query)) /
88
88
+
F64(document.freqs.size());
89
89
+
++df;
90
90
+
matches.push_back({document.filename, tf});
91
91
+
}
92
92
+
}
93
93
+
94
94
+
for (var & [ _, count ] : matches) {
95
95
+
count /= df;
96
96
+
}
97
97
+
return matches;
98
98
+
}
99
99
+
100
100
+
void cache_index(Ref<const Vector<Document>> documents) noexcept
101
101
+
{
102
102
+
std::cout << "caching index in: ";
103
103
+
using namespace std::filesystem;
104
104
+
/* check if cache dir exists and has an index */
105
105
+
let cache_dir = get_cache_dir();
106
106
+
create_directories(cache_dir);
107
107
+
let cache = cache_dir / "cache.txt"s;
108
108
+
109
109
+
std::cout << cache << std::endl;
110
110
+
111
111
+
/* index into cache dir */
112
112
+
var f = std::ofstream();
113
113
+
if (not exists(cache)) {
114
114
+
f.open(cache.c_str());
115
115
+
for (let& document : documents) {
116
116
+
f << document.filename << ' ' << document.freqs.size() << '\n';
117
117
+
for (let& [word, count] : document.freqs) {
118
118
+
f << word << ' ' << count << '\n';
119
119
+
}
120
120
+
}
121
121
+
f.close();
122
122
+
}
123
123
+
}
124
124
+
125
125
+
fn get_cache_dir() noexcept -> std::filesystem::path
126
126
+
{
127
127
+
using namespace std::filesystem;
128
128
+
var cache_dir = String();
129
129
+
if (std::getenv("XDG_CACHE_HOME")) {
130
130
+
cache_dir = path(std::getenv("XDG_CACHE_HOME")) / "stl-index";
131
131
+
} else if (std::getenv("HOME")) {
132
132
+
cache_dir = path(std::getenv("HOME")) / ".cache" / "stl-index";
133
133
+
} else {
134
134
+
cache_dir = path(".");
135
135
+
std::cerr << "Cache directory not found at `$XDG_CACHE_HOME` or `$HOME/.cache`." << std::endl;
136
136
+
std::cerr << "Cache will be dumped in the current directory. Do with it what you will." << std::endl;
137
137
+
}
138
138
+
139
139
+
return cache_dir;
140
140
+
}
141
141
+
142
142
+
fn load_index() noexcept -> Vector<Document>
143
143
+
{
144
144
+
std::cout << "loading index from: ";
145
145
+
var documents = Vector<Document>();
146
146
+
let cache_dir = get_cache_dir();
147
147
+
var cache = std::ifstream();
148
148
+
var path = cache_dir / "cache.txt";
149
149
+
std::cout << path << std::endl;
150
150
+
cache.open(path);
151
151
+
if (cache.is_open()) {
152
152
+
var n = 0ULL;
153
153
+
var count = 0ULL;
154
154
+
while (not cache.eof()) {
155
155
+
var freqs = Vector<std::pair<String, U64>>();
156
156
+
var filename = String();
157
157
+
var word = String();
158
158
+
cache >> filename;
159
159
+
cache >> n;
160
160
+
while (n-- && not cache.eof()) {
161
161
+
cache >> word;
162
162
+
cache >> count;
163
163
+
freqs.push_back({ word, count });
164
164
+
}
165
165
+
documents.emplace_back(filename, std::unordered_map(freqs.cbegin(), freqs.cend()));
166
166
+
}
167
167
+
}
168
168
+
169
169
+
return documents;
170
170
+
}
171
171
+
172
172
+
Document::Document(std::string_view name, map<String, U64>&& mp)
173
173
+
: freqs(mp), filename(name)
174
174
+
{
175
175
+
}
176
176
+
177
177
+
Document::Document(std::string_view name) : filename(name)
178
178
+
{
179
179
+
var f = std::ifstream(filename);
180
180
+
181
181
+
if (not f.is_open()) {
182
182
+
std::cout << "Failed to open: " << name << std::endl;
183
183
+
} else {
184
184
+
/* weird notation for converting a file to string */
185
185
+
var buffer = std::stringstream();
186
186
+
buffer << f.rdbuf();
187
187
+
let html = buffer.str();
188
188
+
189
189
+
let words = to_words(filter_divs(html));
190
190
+
for (let& str : words)
191
191
+
++freqs[str];
192
192
+
}
193
193
+
}
194
194
+
195
195
+
void Document::show_freqs() const noexcept
196
196
+
{
197
197
+
for (let & [ term, freq ] : freqs)
198
198
+
std::cout << term << ": " << freq << std::endl;
199
199
+
}
200
200
+
201
201
+
fn top_n_matches(Ref<const Vector<Document>> documents, Ref<const String> query, U64 n) noexcept
202
202
+
-> Vector<std::pair<String, F64>>
203
203
+
{
204
204
+
var matches = count_tfidf(documents, query);
205
205
+
let greater = [](let& x, let& y) { return x.second > y.second; };
206
206
+
if (matches.size() < n)
207
207
+
ra::sort(matches, greater);
208
208
+
else
209
209
+
ra::partial_sort(matches, matches.begin() + n, greater);
210
210
+
211
211
+
matches.resize(n);
212
212
+
213
213
+
return matches;
214
214
+
}
+45
src/indexer.hpp
···
1
1
+
#pragma once
2
2
+
#include "prelude.hpp"
3
3
+
#include <filesystem>
4
4
+
#include <fstream>
5
5
+
#include <iostream>
6
6
+
#include <ranges>
7
7
+
#include <sstream>
8
8
+
#include <unordered_map>
9
9
+
10
10
+
template <typename Key, typename Value>
11
11
+
using map = std::unordered_map<Key, Value>;
12
12
+
13
13
+
struct Document {
14
14
+
map<String, U64> freqs;
15
15
+
String filename;
16
16
+
17
17
+
Document(std::string_view name, map<String, U64>&& mp);
18
18
+
19
19
+
Document(std::string_view name);
20
20
+
21
21
+
void show_freqs() const noexcept;
22
22
+
};
23
23
+
24
24
+
fn filter_divs(std::string_view html) noexcept -> String;
25
25
+
26
26
+
fn to_words(std::string_view lines) noexcept -> Vector<String>;
27
27
+
28
28
+
fn index_directory(std::filesystem::path dir) noexcept -> Vector<Document>;
29
29
+
30
30
+
void cache_index(Ref<const Vector<Document>> documents) noexcept;
31
31
+
32
32
+
fn load_index() noexcept -> Vector<Document>;
33
33
+
34
34
+
fn get_cache_dir() noexcept -> std::filesystem::path;
35
35
+
36
36
+
fn count_query(Ref<const Vector<Document>> documents,
37
37
+
Ref<const String> query) noexcept
38
38
+
-> Vector<std::pair<String, F64>>;
39
39
+
40
40
+
fn count_tfidf(Ref<const Vector<Document>> documents,
41
41
+
Ref<const String> query) noexcept
42
42
+
-> Vector<std::pair<String, F64>>;
43
43
+
44
44
+
fn top_n_matches(Ref<const Vector<Document>> documents, Ref<const String> query, U64 n) noexcept
45
45
+
-> Vector<std::pair<String, F64>>;
+52
src/main.cpp
···
1
1
+
/* ========================================================================
2
2
+
*
3
3
+
* Filename: main.cpp
4
4
+
* Description: HTML Parser and Browser for cppreference
5
5
+
* Author: Diego A. Estrada Rivera
6
6
+
* Version: 0.0.1
7
7
+
*
8
8
+
* ======================================================================== */
9
9
+
#include "indexer.hpp"
10
10
+
#include "prelude.hpp"
11
11
+
#include <cctype>
12
12
+
13
13
+
namespace filesystem = std::filesystem;
14
14
+
15
15
+
proc Main([[maybe_unused]] std::span<const std::string_view> args) noexcept
16
16
+
-> I32
17
17
+
{
18
18
+
let cppref =
19
19
+
filesystem::path{"/home/Michorron/Git/cppreference-doc/"
20
20
+
"reference/en.cppreference.com"};
21
21
+
22
22
+
let cache = get_cache_dir() / "cache.txt";
23
23
+
var cache_created = exists(cache);
24
24
+
let documents = cache_created ? load_index() : index_directory(cppref) ;
25
25
+
if (not cache_created) cache_index(documents);
26
26
+
27
27
+
std::cout << "Succesfully indexed " << cppref.filename() << "!"
28
28
+
<< std::endl;
29
29
+
30
30
+
var query = String();
31
31
+
std::cout << "What is your query?\nType here: ";
32
32
+
std::getline(std::cin, query);
33
33
+
34
34
+
cache_index(documents);
35
35
+
36
36
+
let greater = [](let& x, let& y) { return x.second > y.second; };
37
37
+
38
38
+
for (var& c : query) c = std::toupper(c);
39
39
+
var matches = count_tfidf(documents, query);
40
40
+
if (matches.size() < 5)
41
41
+
ra::sort(matches, greater);
42
42
+
else
43
43
+
ra::partial_sort(matches, matches.begin() + 5, greater);
44
44
+
45
45
+
for (var idx = 0LLU; let & [ name, score ] : matches) {
46
46
+
if (idx > 5)
47
47
+
break;
48
48
+
std::cout << name << " had " << score << " score.\n";
49
49
+
++idx;
50
50
+
}
51
51
+
return 0;
52
52
+
}
+48
src/prelude.cpp
···
1
1
+
/* ========================================================================
2
2
+
*
3
3
+
* Filename: prelude.hpp
4
4
+
* Description: C++ sensible prelude - Definitions
5
5
+
* Author: Diego A. Estrada Rivera
6
6
+
* Version: 0.0.4
7
7
+
*
8
8
+
* ======================================================================== */
9
9
+
#include "prelude.hpp"
10
10
+
#include <ranges>
11
11
+
12
12
+
/* type-safe main */
13
13
+
I32 main(const I32 argc, const Handle<const CString> argv)
14
14
+
{
15
15
+
proc Main(std::span<const std::string_view>) noexcept -> I32;
16
16
+
let args = std::vector<std::string_view>(
17
17
+
argv, std::next(argv, static_cast<std::ptrdiff_t>(argc)));
18
18
+
return Main(args);
19
19
+
}
20
20
+
21
21
+
/* Sensible IO */
22
22
+
#include <iostream>
23
23
+
24
24
+
proc getLine() noexcept -> String
25
25
+
{
26
26
+
var str = String();
27
27
+
getline(std::cin, str);
28
28
+
return str;
29
29
+
}
30
30
+
31
31
+
proc getChar() noexcept -> Char
32
32
+
{
33
33
+
var c = Char();
34
34
+
std::cin >> c;
35
35
+
return c;
36
36
+
}
37
37
+
38
38
+
proc print(const std::string_view& f) noexcept -> Unit
39
39
+
{
40
40
+
std::cout << f;
41
41
+
return Unit();
42
42
+
}
43
43
+
44
44
+
proc println(const std::string_view& f) noexcept -> Unit
45
45
+
{
46
46
+
std::cout << f << std::endl;
47
47
+
return Unit();
48
48
+
}
+141
src/prelude.hpp
···
1
1
+
/* ========================================================================
2
2
+
*
3
3
+
* Filename: prelude.hpp
4
4
+
* Description: C++ sensible prelude - Declarations
5
5
+
* Author: Diego A. Estrada Rivera
6
6
+
* Version: 0.0.4
7
7
+
*
8
8
+
* ======================================================================== */
9
9
+
#pragma once
10
10
+
11
11
+
/* === Generic includes === */
12
12
+
#include <list>
13
13
+
14
14
+
#include <queue>
15
15
+
#include <span>
16
16
+
#include <stack>
17
17
+
#include <unordered_map>
18
18
+
#include <unordered_set>
19
19
+
20
20
+
#include <algorithm>
21
21
+
#include <numeric>
22
22
+
#include <ranges>
23
23
+
24
24
+
#include <format>
25
25
+
#include <fstream>
26
26
+
27
27
+
/* === Numeric Types === */
28
28
+
#include <cstdint>
29
29
+
#include <limits.h>
30
30
+
using Size = std::size_t;
31
31
+
32
32
+
/* Floating Point */
33
33
+
// brain floating point
34
34
+
// see https://en.wikipedia.org/wiki/Bfloat16_floating-point_format
35
35
+
typedef __bf16 BF16;
36
36
+
typedef _Float16 F16;
37
37
+
typedef float F32;
38
38
+
static_assert(sizeof(F32) * CHAR_BIT == 32); //
39
39
+
typedef double F64;
40
40
+
static_assert(sizeof(F64) * CHAR_BIT == 64);
41
41
+
#if __float80_max < __float128_max
42
42
+
typedef __float80 F80; // sometimes is the same as F128
43
43
+
#endif
44
44
+
typedef __float128 F128;
45
45
+
46
46
+
// decimal floating points
47
47
+
// see decimal32/64/128 in https://en.wikipedia.org/wiki/IEEE_754
48
48
+
#if 0
49
49
+
typedef float __attribute__((mode(SD))) D32;
50
50
+
typedef float __attribute__((mode(DD))) D64;
51
51
+
typedef float __attribute__((mode(TD))) D128;
52
52
+
#endif
53
53
+
54
54
+
/* Integer */
55
55
+
typedef uint8_t U8;
56
56
+
typedef uint16_t U16;
57
57
+
typedef uint32_t U32;
58
58
+
typedef uint64_t U64;
59
59
+
typedef __uint128_t U128;
60
60
+
61
61
+
typedef int8_t I8;
62
62
+
typedef int16_t I16;
63
63
+
typedef int32_t I32;
64
64
+
typedef int64_t I64;
65
65
+
typedef __int128_t I128;
66
66
+
67
67
+
// generic Integer type
68
68
+
typedef int_fast32_t Int;
69
69
+
70
70
+
/* === Other Types === */
71
71
+
typedef bool Bool;
72
72
+
typedef char Char;
73
73
+
typedef const char* CString;
74
74
+
75
75
+
#include <vector>
76
76
+
template <typename T> using Vector = std::vector<T>;
77
77
+
78
78
+
#include <string>
79
79
+
using String = std::string;
80
80
+
using namespace std::string_literals;
81
81
+
82
82
+
namespace ra = std::ranges;
83
83
+
namespace vi = std::ranges::views;
84
84
+
85
85
+
// Unit type
86
86
+
enum class Unit { unit };
87
87
+
88
88
+
// Void type
89
89
+
enum class Void {};
90
90
+
91
91
+
// Pointer types
92
92
+
template <typename T> using Ref = T&;
93
93
+
94
94
+
template <typename T> using Handle = T*;
95
95
+
96
96
+
/* === Keywords === */
97
97
+
#define let auto const
98
98
+
#define var auto
99
99
+
#define fn [[nodiscard, gnu::const]] auto
100
100
+
#define proc [[nodiscard]] auto
101
101
+
102
102
+
/* This is included as a static member variable of <tuple>.
103
103
+
* However, there is no way to bring the std::ignore namespace static variable
104
104
+
* into the current scope. This is a way to do that.
105
105
+
* https://en.cppreference.com/w/cpp/utility/tuple/ignore
106
106
+
*/
107
107
+
namespace detail {
108
108
+
struct ignore_t {
109
109
+
template <typename T>
110
110
+
constexpr // required since C++14
111
111
+
void
112
112
+
operator=(T&&) const noexcept
113
113
+
{
114
114
+
}
115
115
+
};
116
116
+
} // namespace detail
117
117
+
inline constinit const detail::ignore_t ignore; // changed to constinit
118
118
+
119
119
+
// manage tuples better
120
120
+
#define fst std::get<0>
121
121
+
#define snd std::get<1>
122
122
+
#define thr std::get<2>
123
123
+
124
124
+
/* === Miscellaneous Functions */
125
125
+
template <class D, class C> fn memoize(let& op) noexcept
126
126
+
{
127
127
+
static var mp = std::unordered_map<D, C>();
128
128
+
return [=](D const& x) noexcept {
129
129
+
return mp.contains(x) ? mp.at(x) : mp[x] = op(x);
130
130
+
};
131
131
+
}
132
132
+
133
133
+
/* Sensible IO */
134
134
+
#include <iostream>
135
135
+
proc getLine() noexcept -> String;
136
136
+
137
137
+
proc getChar() noexcept -> Char;
138
138
+
139
139
+
proc print(const std::string_view& f) noexcept -> Unit;
140
140
+
141
141
+
proc println(const std::string_view& f) noexcept -> Unit;