C++ Standard Template Library browser.

first commit

Sunglas 9da94c69

+1960
+10
.clang-format
··· 1 + BasedOnStyle: LLVM 2 + IndentWidth: 8 3 + UseTab: Always 4 + AllowShortIfStatementsOnASingleLine: false 5 + IndentCaseLabels: false 6 + PointerAlignment: Left 7 + AllowShortFunctionsOnASingleLine: None 8 + BreakBeforeBraces: Custom 9 + BraceWrapping: 10 + AfterFunction: true
+2
.clangd
··· 1 + CompileFlags: 2 + Add: [-std=c++20]
+22
Makefile
··· 1 + .POSIX: 2 + 3 + CXX=g++ 4 + WARNINGS=-Werror -Wall -Wextra 5 + CXXFLAGS=-std=c++2b $(WARNINGS) 6 + SRC=src/*.cpp 7 + HEADERS=src/*.hpp 8 + BUILD=build 9 + 10 + build: src/main.cpp 11 + $(CXX) $(SRC) -g -o $(BUILD)/a.out $(CXXFLAGS) 12 + 13 + run: build 14 + ./$(BUILD)/a.out $(ARGS) 15 + 16 + test: 17 + ./$(BUILD)/a.out $(ARGS) 18 + 19 + format: 20 + clang-format -i $(SRC) $(HEADERS) 21 + 22 + .PHONY: build run format
+1426
basic_ifstream.html
··· 1 + <!DOCTYPE html> 2 + <html lang="en" dir="ltr" class="client-nojs"> 3 + <head> 4 + <title>std::basic_ifstream - cppreference.com</title> 5 + <meta charset="UTF-8" /> 6 + <meta name="generator" content="MediaWiki 1.21.2" /> 7 + <link rel="alternate" type="application/x-wiki" title="Edit" href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&amp;action=edit" /> 8 + <link rel="edit" title="Edit" href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&amp;action=edit" /> 9 + <link rel="shortcut icon" href="../../../favicon.ico" /> 10 + <link rel="search" type="application/opensearchdescription+xml" href="../../../mwiki/opensearch_desc.php" title="cppreference.com (en)" /> 11 + <link rel="EditURI" type="application/rsd+xml" href="https://en.cppreference.com/mwiki/api.php?action=rsd" /> 12 + <link rel="alternate" type="application/atom+xml" title="cppreference.com Atom feed" href="https://en.cppreference.com/mwiki/index.php?title=Special:RecentChanges&amp;feed=atom" /> 13 + <link rel="stylesheet" href="../../../mwiki/load.php%3Fdebug=false&amp;lang=en&amp;modules=ext.gadget.ColiruCompiler,MathJax|ext.rtlcite|mediawiki.legacy.commonPrint,shared|skins.cppreference2&amp;only=styles&amp;skin=cppreference2&amp;*.css" /> 14 + <meta name="ResourceLoaderDynamicStyles" content="" /> 15 + <link rel="stylesheet" href="../../../mwiki/load.php%3Fdebug=false&amp;lang=en&amp;modules=site&amp;only=styles&amp;skin=cppreference2&amp;*.css" /> 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 + /* cache key: mwiki1-mwiki_en_:resourceloader:filter:minify-css:7:472787eddcf4605d11de8c7ef047234f */</style> 18 + 19 + <script src="../../../mwiki/load.php%3Fdebug=false&amp;lang=en&amp;modules=startup&amp;only=scripts&amp;skin=cppreference2&amp;*"></script> 20 + <script>if(window.mw){ 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 + }</script><script>if(window.mw){ 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 + "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 + /* cache key: mwiki1-mwiki_en_:resourceloader:filter:minify-js:7:9f05c6caceb9bb1a482b6cebd4c5a330 */ 26 + }</script> 27 + <script>if(window.mw){ 28 + mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]); 29 + }</script> 30 + <style type="text/css">/*<![CDATA[*/ 31 + .source-cpp {line-height: normal;} 32 + .source-cpp li, .source-cpp pre { 33 + line-height: normal; border: 0px none white; 34 + } 35 + /** 36 + * GeSHi Dynamically Generated Stylesheet 37 + * -------------------------------------- 38 + * Dynamically generated stylesheet for cpp 39 + * CSS class: source-cpp, CSS id: 40 + * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann 41 + * (http://qbnz.com/highlighter/ and http://geshi.org/) 42 + * -------------------------------------- 43 + */ 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 + .cpp.source-cpp {font-family:monospace;} 46 + .cpp.source-cpp .imp {font-weight: bold; color: red;} 47 + .cpp.source-cpp li, .cpp.source-cpp .li1 {font-weight: normal; vertical-align:top;} 48 + .cpp.source-cpp .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;} 49 + .cpp.source-cpp .li2 {font-weight: bold; vertical-align:top;} 50 + .cpp.source-cpp .kw1 {color: #0000dd;} 51 + .cpp.source-cpp .kw2 {color: #0000ff;} 52 + .cpp.source-cpp .kw3 {color: #0000dd;} 53 + .cpp.source-cpp .kw4 {color: #0000ff;} 54 + .cpp.source-cpp .co1 {color: #909090;} 55 + .cpp.source-cpp .co2 {color: #339900;} 56 + .cpp.source-cpp .coMULTI {color: #ff0000; font-style: italic;} 57 + .cpp.source-cpp .es0 {color: #008000; font-weight: bold;} 58 + .cpp.source-cpp .es1 {color: #008000; font-weight: bold;} 59 + .cpp.source-cpp .es2 {color: #008000; font-weight: bold;} 60 + .cpp.source-cpp .es3 {color: #008000; font-weight: bold;} 61 + .cpp.source-cpp .es4 {color: #008000; font-weight: bold;} 62 + .cpp.source-cpp .es5 {color: #008000; font-weight: bold;} 63 + .cpp.source-cpp .br0 {color: #008000;} 64 + .cpp.source-cpp .sy0 {color: #008000;} 65 + .cpp.source-cpp .sy1 {color: #000080;} 66 + .cpp.source-cpp .sy2 {color: #000040;} 67 + .cpp.source-cpp .sy3 {color: #000040;} 68 + .cpp.source-cpp .sy4 {color: #008080;} 69 + .cpp.source-cpp .st0 {color: #008000;} 70 + .cpp.source-cpp .nu0 {color: #000080;} 71 + .cpp.source-cpp .nu6 {color: #000080;} 72 + .cpp.source-cpp .nu8 {color: #000080;} 73 + .cpp.source-cpp .nu12 {color: #000080;} 74 + .cpp.source-cpp .nu16 {color:#000080;} 75 + .cpp.source-cpp .nu17 {color:#000080;} 76 + .cpp.source-cpp .nu18 {color:#000080;} 77 + .cpp.source-cpp .nu19 {color:#000080;} 78 + .cpp.source-cpp .ln-xtra, .cpp.source-cpp li.ln-xtra, .cpp.source-cpp div.ln-xtra {background-color: #ffc;} 79 + .cpp.source-cpp span.xtra { display:block; } 80 + 81 + /*]]>*/ 82 + </style><style type="text/css">/*<![CDATA[*/ 83 + .source-text {line-height: normal;} 84 + .source-text li, .source-text pre { 85 + line-height: normal; border: 0px none white; 86 + } 87 + /** 88 + * GeSHi Dynamically Generated Stylesheet 89 + * -------------------------------------- 90 + * Dynamically generated stylesheet for text 91 + * CSS class: source-text, CSS id: 92 + * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann 93 + * (http://qbnz.com/highlighter/ and http://geshi.org/) 94 + * -------------------------------------- 95 + */ 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 + .text.source-text {font-family:monospace;} 98 + .text.source-text .imp {font-weight: bold; color: red;} 99 + .text.source-text li, .text.source-text .li1 {font-weight: normal; vertical-align:top;} 100 + .text.source-text .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;} 101 + .text.source-text .li2 {font-weight: bold; vertical-align:top;} 102 + .text.source-text .ln-xtra, .text.source-text li.ln-xtra, .text.source-text div.ln-xtra {background-color: #ffc;} 103 + .text.source-text span.xtra { display:block; } 104 + 105 + /*]]>*/ 106 + </style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]--></head> 107 + <body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_io_basic_ifstream skin-cppreference2 action-view cpp-navbar"> 108 + <!-- header --> 109 + <div id="mw-head" class="noprint"> 110 + <div id="cpp-head-first-base"> 111 + <div id="cpp-head-first"> 112 + <h5><a href="../../../index.html"> 113 + cppreference.com </a></h5> 114 + <div id="cpp-head-search"> 115 + 116 + <!-- 0 --> 117 + <div id="p-search"> 118 + <form action="https://duckduckgo.com/" method="get"> 119 + <input type="hidden" name="sites" value="cppreference.com"> 120 + <input type="search" name="q"> 121 + <input type="submit" value="Search"> 122 + </form> 123 + </div> 124 + 125 + <!-- /0 --> 126 + </div> 127 + <div id="cpp-head-personal"> 128 + 129 + <!-- 0 --> 130 + <div id="p-personal" class=""> 131 + <span id="pt-login"><a href="https://en.cppreference.com/mwiki/index.php?title=Special:UserLogin&amp;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 + 133 + <!-- /0 --> 134 + </div> 135 + 136 + </div> 137 + </div> 138 + <div id="cpp-head-second-base"> 139 + <div id="cpp-head-second"> 140 + <div id="cpp-head-tools-left"> 141 + 142 + <!-- 0 --> 143 + <div id="p-namespaces" class="vectorTabs"> 144 + <h5>Namespaces</h5> 145 + <ul> 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 + <li id="ca-talk" class="new"><span><a href="https://en.cppreference.com/mwiki/index.php?title=Talk:cpp/io/basic_ifstream&amp;action=edit&amp;redlink=1" title="Discussion about the content page [t]" accesskey="t">Discussion</a></span></li> 148 + </ul> 149 + </div> 150 + 151 + <!-- /0 --> 152 + 153 + <!-- 1 --> 154 + <div id="p-variants" class="vectorMenu emptyPortlet"> 155 + <h5><span>Variants</span><a href="basic_ifstream.html#"></a></h5> 156 + <div class="menu"> 157 + <ul> 158 + </ul> 159 + </div> 160 + </div> 161 + 162 + <!-- /1 --> 163 + </div> 164 + <div id="cpp-head-tools-right"> 165 + 166 + <!-- 0 --> 167 + <div id="p-views" class="vectorTabs"> 168 + <h5>Views</h5> 169 + <ul> 170 + <li id="ca-view" class="selected"><span><a href="basic_ifstream.html" >View</a></span></li> 171 + <li id="ca-edit"><span><a href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&amp;action=edit" title="You can edit this page. Please use the preview button before saving [e]" accesskey="e">Edit</a></span></li> 172 + <li id="ca-history" class="collapsible"><span><a href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&amp;action=history" title="Past revisions of this page [h]" accesskey="h">History</a></span></li> 173 + </ul> 174 + </div> 175 + 176 + <!-- /0 --> 177 + 178 + <!-- 1 --> 179 + <div id="p-cactions" class="vectorMenu emptyPortlet"> 180 + <h5><span>Actions</span><a href="basic_ifstream.html#"></a></h5> 181 + <div class="menu"> 182 + <ul> 183 + </ul> 184 + </div> 185 + </div> 186 + 187 + <!-- /1 --> 188 + </div> 189 + </div> 190 + </div> 191 + </div> 192 + <!-- /header --> 193 + <!-- content --> 194 + <style type="text/css"> 195 + #carbonads { 196 + display: block; 197 + overflow: hidden; 198 + position: absolute; 199 + text-align: center; 200 + left: -170px; 201 + max-width: 150px; 202 + border-radius: 4px; 203 + border: solid 1px hsla(0, 0%, 0%, .1); 204 + background-color: hsl(0, 0%, 98%); 205 + font-size: 12px; 206 + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, 207 + Cantarell, "Helvetica Neue", Helvetica, Arial, sans-serif; 208 + line-height: 1.5; 209 + } 210 + 211 + #carbonads a { 212 + color: inherit; 213 + text-decoration: none; 214 + } 215 + 216 + #carbonads a:hover { 217 + color: inherit; 218 + } 219 + 220 + #carbonads span { 221 + position: relative; 222 + display: block; 223 + overflow: hidden; 224 + } 225 + 226 + .carbon-img { 227 + display: block; 228 + margin-bottom: 8px; 229 + max-width: 150px; 230 + line-height: 1; 231 + } 232 + 233 + .carbon-img img { 234 + display: block; 235 + margin: 0 auto; 236 + max-width: 150px !important; 237 + width: 150px; 238 + height: auto; 239 + } 240 + 241 + .carbon-text { 242 + display: block; 243 + padding: 0 1em 8px; 244 + } 245 + 246 + .carbon-poweredby { 247 + display: block; 248 + padding: 8px 12px; 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 + text-transform: uppercase; 251 + letter-spacing: .5px; 252 + font-weight: 600; 253 + font-size: 9px; 254 + line-height: 1; 255 + } 256 + html { font-variant-ligatures: no-common-ligatures; } 257 + </style> 258 + <div id="cpp-content-base"> 259 + <div id="content"> 260 + <a id="top"></a> 261 + <div id="mw-js-message" style="display:none;"></div> 262 + <!-- firstHeading --> 263 + <script async type="text/javascript" src="https://cdn.carbonads.com/carbon.js?serve=CKYITK7M&amp;placement=cppreferencecom" id="_carbonads_js"></script> 264 + <h1 id="firstHeading" class="firstHeading"><span style="font-size:0.7em; line-height:130%">std::</span>basic_ifstream</h1> 265 + <!-- /firstHeading --> 266 + <!-- bodyContent --> 267 + <div id="bodyContent"> 268 + <!-- tagline --> 269 + <div id="siteSub">From cppreference.com</div> 270 + <!-- /tagline --> 271 + <!-- subtitle --> 272 + <div id="contentSub"><span class="subpages">&lt; <a href="../../cpp.html" title="cpp">cpp</a>&lrm; | <a href="../io.html" title="cpp/io">io</a></span></div> 273 + <!-- /subtitle --> 274 + <!-- bodycontent --> 275 + <div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><div class="t-navbar" style=""><div class="t-navbar-sep">&#160;</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 + <tr class="t-nv"><td colspan="5"><a href="../compiler_support.html" title="cpp/compiler support">Compiler support</a></td></tr> 277 + <tr class="t-nv"><td colspan="5"><a href="../freestanding.html" title="cpp/freestanding">Freestanding and hosted</a></td></tr> 278 + <tr class="t-nv"><td colspan="5"><a href="../language.html" title="cpp/language">Language</a></td></tr> 279 + <tr class="t-nv"><td colspan="5"><a href="../standard_library.html" title="cpp/standard library">Standard library</a></td></tr> 280 + <tr class="t-nv"><td colspan="5"><a href="../headers.html" title="cpp/header">Standard library headers</a></td></tr> 281 + <tr class="t-nv"><td colspan="5"><a href="../named_req.html" title="cpp/named req">Named requirements</a></td></tr> 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 + <tr class="t-nv"><td colspan="5"><a href="../utility.html#Language_support" title="cpp/utility">Language support library</a></td></tr> 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 + <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 + <tr class="t-nv"><td colspan="5"><a href="../error.html" title="cpp/error">Diagnostics library</a></td></tr> 287 + <tr class="t-nv"><td colspan="5"><a href="../utility.html" title="cpp/utility">General utilities library</a></td></tr> 288 + <tr class="t-nv"><td colspan="5"><a href="../string.html" title="cpp/string">Strings library</a></td></tr> 289 + <tr class="t-nv"><td colspan="5"><a href="../container.html" title="cpp/container">Containers library</a></td></tr> 290 + <tr class="t-nv"><td colspan="5"><a href="../iterator.html" title="cpp/iterator">Iterators library</a></td></tr> 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 + <tr class="t-nv"><td colspan="5"><a href="../algorithm.html" title="cpp/algorithm">Algorithms library</a></td></tr> 293 + <tr class="t-nv"><td colspan="5"><a href="../numeric.html" title="cpp/numeric">Numerics library</a></td></tr> 294 + <tr class="t-nv"><td colspan="5"><a href="../locale.html" title="cpp/locale">Localizations library</a></td></tr> 295 + <tr class="t-nv"><td colspan="5"><a href="../io.html" title="cpp/io">Input/output library</a></td></tr> 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 + <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 + <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 + <tr class="t-nv"><td colspan="5"><a href="../experimental.html" title="cpp/experimental">Technical specifications</a></td></tr> 300 + <tr class="t-nv"><td colspan="5"><a href="../symbol_index.html" title="cpp/symbol index">Symbols index</a></td></tr> 301 + <tr class="t-nv"><td colspan="5"><a href="../links/libs.html" title="cpp/links/libs">External libraries</a></td></tr> 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&amp;action=edit">&#91;edit&#93;</a></span></div></div></div></div><div class="t-navbar-sep">&#160;</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 + <tr class="t-nv"><td colspan="5"> <a href="manip.html" title="cpp/io/manip"> I/O manipulators</a></td></tr> 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 + <tr class="t-nv"><td colspan="5"> <a href="c.html" title="cpp/io/c"> C-style I/O</a></td></tr> 306 + <tr class="t-nv-h1"><td colspan="5"> Buffers</td></tr> 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 + <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 + <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 + <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 + <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 + <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 + <tr class="t-nv-h1"><td colspan="5"> Streams</td></tr> 314 + <tr class="t-nv-h2"><td colspan="5"> Abstractions</td></tr> 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 + <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 + <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 + <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 + <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 + <tr class="t-nv-h2"><td colspan="5"> File I/O</td></tr> 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 + <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 + <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 + <tr class="t-nv-h2"><td colspan="5"> String I/O</td></tr> 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 + <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 + <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 + <tr class="t-nv-h2"><td colspan="5"> Array I/O</td></tr> 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 + <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 + <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 + <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 + <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 + <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 + <tr class="t-nv-h2"><td colspan="5"> Synchronized Output</td></tr> 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 + <tr class="t-nv-h1"><td colspan="5"> Types</td></tr> 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 + <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 + <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 + <tr class="t-nv-h1"><td colspan="5"> Error category interface</td></tr> 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 + <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 + </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&amp;action=edit">&#91;edit&#93;</a></span></div></div></div></div><div class="t-navbar-sep">&#160;</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 + <tr class="t-nv-h1"><td colspan="5"> Member functions</td></tr> 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 + <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 + <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 + <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 + <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 + <tr class="t-nv-h2"><td colspan="5"> File operations </td></tr> 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 + <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 + <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 + <tr class="t-nv-h1"><td colspan="5"> Non-member functions </td></tr> 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 + </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&amp;action=edit">&#91;edit&#93;</a></span></div></div></div></div><div class="t-navbar-sep">&#160;</div></div> 358 + <table class="t-dcl-begin"><tbody> 359 + <tr class="t-dsc-header"> 360 + <td> <div>Defined in header <code><a href="../header/fstream.html" title="cpp/header/fstream">&lt;fstream&gt;</a></code> 361 + </div></td> 362 + <td></td> 363 + <td></td> 364 + </tr> 365 + <tr class="t-dcl"> 366 + <td class="t-dcl-nopad"> <div><span class="mw-geshi cpp source-cpp"><span class="kw1">template</span><span class="sy1">&lt;</span> <br /> 367 + <p>&#160; &#160; <span class="kw1">class</span> CharT, <br /> 368 + &#160; &#160; <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">&lt;</span>CharT<span class="sy1">&gt;</span><br /> 369 + </p> 370 + <span class="sy1">&gt;</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">&lt;</span>CharT, Traits<span class="sy1">&gt;</span></span></div></td> 371 + <td class="t-dcl-nopad"> </td> 372 + <td class="t-dcl-nopad"> </td> 373 + </tr> 374 + <tr class="t-dcl-sep"><td></td><td></td><td></td></tr> 375 + </tbody></table> 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 + </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">&lt;</span>CharT, Traits<span class="sy1">&gt;</span></span>. 378 + </p> 379 + <div class="t-inheritance-diagram"> 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 + <div style="text-align:center;"> 382 + <p><span style="font-size:0.7em; line-height:130%">Inheritance diagram</span> 383 + </p> 384 + </div> 385 + </div> 386 + <p>Several typedefs for common character types are provided: 387 + </p> 388 + <table class="t-dsc-begin"> 389 + 390 + <tr class="t-dsc-header"> 391 + <td colspan="2"> <div>Defined in header <code><a href="../header/fstream.html" title="cpp/header/fstream">&lt;fstream&gt;</a></code> </div> 392 + </td></tr> 393 + 394 + <tr class="t-dsc-hitem"> 395 + <td> Type 396 + </td> 397 + <td> Definition 398 + </td></tr> 399 + 400 + 401 + <tr class="t-dsc"> 402 + <td> <code>std::ifstream</code> 403 + </td> 404 + <td> <span class="mw-geshi cpp source-cpp">std<span class="sy4">::</span><span class="me2">basic_ifstream</span><span class="sy1">&lt;</span><span class="kw4">char</span><span class="sy1">&gt;</span></span> 405 + </td></tr> 406 + 407 + 408 + <tr class="t-dsc"> 409 + <td> <code>std::wifstream</code> 410 + </td> 411 + <td> <span class="mw-geshi cpp source-cpp">std<span class="sy4">::</span><span class="me2">basic_ifstream</span><span class="sy1">&lt;</span><span class="kw4">wchar_t</span><span class="sy1">&gt;</span></span> 412 + </td></tr> 413 + 414 + </table> 415 + <table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> 416 + <ul> 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 + <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 + <ul> 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 + </ul> 422 + </li> 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 + <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 + <ul> 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 + <ul> 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 + <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 + <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 + <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 + </ul> 433 + </li> 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 + </ul> 436 + </li> 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 + <ul> 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 + <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 + <ul> 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 + <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 + <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 + </ul> 446 + </li> 447 + </ul> 448 + </li> 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 + <ul> 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 + <ul> 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 + <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 + <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 + <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 + <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 + </ul> 459 + </li> 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 + <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 + <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 + </ul> 464 + </li> 465 + </ul> 466 + </td></tr></table> 467 + <h3><span class="editsection">[<a href="https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/member_types&amp;action=edit&amp;section=T-1" title="Template:cpp/io/member types">edit</a>]</span> <span class="mw-headline" id="Member_types">Member types</span></h3> 468 + <table class="t-dsc-begin"> 469 + 470 + <tr class="t-dsc-hitem"> 471 + <td> Member type 472 + </td> 473 + <td> Definition 474 + </td></tr> 475 + 476 + 477 + <tr class="t-dsc"> 478 + <td> <code>char_type</code> 479 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 481 + </td></tr> 482 + 483 + <tr class="t-dsc"> 484 + <td> <code>traits_type</code> 485 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 487 + </td></tr> 488 + 489 + <tr class="t-dsc"> 490 + <td> <code>int_type</code> 491 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 493 + </td></tr> 494 + 495 + <tr class="t-dsc"> 496 + <td> <code>pos_type</code> 497 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 499 + </td></tr> 500 + 501 + <tr class="t-dsc"> 502 + <td> <code>off_type</code> 503 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 505 + </td></tr> 506 + 507 + <tr class="t-dsc"> 508 + <td> <code>native_handle_type</code><span class="t-mark-rev t-since-cxx26">(C++26)</span> 509 + </td> 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, &#39;DejaVu Serif&#39;, 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&amp;action=edit">&#91;edit&#93;</a></span> 511 + </td></tr> 512 + </table> 513 + <h3><span class="editsection">[<a href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&amp;action=edit&amp;section=1" title="Edit section: Member functions">edit</a>]</span> <span class="mw-headline" id="Member_functions">Member functions</span></h3> 514 + <table class="t-dsc-begin"> 515 + 516 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 520 + </td></tr> 521 + 522 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 526 + </td></tr> 527 + 528 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 532 + </td></tr> 533 + 534 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 538 + </td></tr> 539 + 540 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 544 + </td></tr> 545 + 546 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 550 + </td></tr> 551 + 552 + 553 + <tr> 554 + <td colspan="2"> <h5> <span class="mw-headline" id="File_operations"> File operations </span></h5> 555 + </td></tr> 556 + 557 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 561 + </td></tr> 562 + 563 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 567 + </td></tr> 568 + 569 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 573 + </td></tr> 574 + </table> 575 + <h3><span class="editsection">[<a href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&amp;action=edit&amp;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 + <table class="t-dsc-begin"> 577 + 578 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 582 + </td></tr> 583 + </table> 584 + <div class="t-inherited"> 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 + <h3> <span class="mw-headline" id="Member_functions_2">Member functions</span></h3> 587 + <table class="t-dsc-begin"> 588 + 589 + <tr> 590 + <td colspan="2"> <h5> <span class="mw-headline" id="Formatted_input"> Formatted input </span></h5> 591 + </td></tr> 592 + 593 + <tr class="t-dsc"> 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&gt;&gt;</span></span></a></div></div> 595 + </td> 596 + <td> extracts formatted data <br /> <span class="t-mark">(public member function of <code>std::basic_istream&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 597 + </td></tr> 598 + 599 + 600 + <tr> 601 + <td colspan="2"> <h5> <span class="mw-headline" id="Unformatted_input"> Unformatted input </span></h5> 602 + </td></tr> 603 + 604 + <tr class="t-dsc"> 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 + </td> 607 + <td> extracts characters <br /> <span class="t-mark">(public member function of <code>std::basic_istream&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 608 + </td></tr> 609 + 610 + <tr class="t-dsc"> 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 + </td> 613 + <td> reads the next character without extracting it <br /> <span class="t-mark">(public member function of <code>std::basic_istream&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 614 + </td></tr> 615 + 616 + <tr class="t-dsc"> 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 + </td> 619 + <td> unextracts a character <br /> <span class="t-mark">(public member function of <code>std::basic_istream&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 620 + </td></tr> 621 + 622 + <tr class="t-dsc"> 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 + </td> 625 + <td> puts a character into input stream <br /> <span class="t-mark">(public member function of <code>std::basic_istream&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 626 + </td></tr> 627 + 628 + <tr class="t-dsc"> 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 + </td> 631 + <td> extracts characters until the given character is found <br /> <span class="t-mark">(public member function of <code>std::basic_istream&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 632 + </td></tr> 633 + 634 + <tr class="t-dsc"> 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 + </td> 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&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 638 + </td></tr> 639 + 640 + <tr class="t-dsc"> 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 + </td> 643 + <td> extracts blocks of characters <br /> <span class="t-mark">(public member function of <code>std::basic_istream&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 644 + </td></tr> 645 + 646 + <tr class="t-dsc"> 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 + </td> 649 + <td> extracts already available blocks of characters <br /> <span class="t-mark">(public member function of <code>std::basic_istream&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 650 + </td></tr> 651 + 652 + <tr class="t-dsc"> 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 + </td> 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&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 656 + </td></tr> 657 + 658 + 659 + <tr> 660 + <td colspan="2"> <h5> <span class="mw-headline" id="Positioning"> Positioning </span></h5> 661 + </td></tr> 662 + 663 + <tr class="t-dsc"> 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 + </td> 666 + <td> returns the input position indicator <br /> <span class="t-mark">(public member function of <code>std::basic_istream&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 667 + </td></tr> 668 + 669 + <tr class="t-dsc"> 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 + </td> 672 + <td> sets the input position indicator <br /> <span class="t-mark">(public member function of <code>std::basic_istream&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 673 + </td></tr> 674 + 675 + 676 + <tr> 677 + <td colspan="2"> <h5> <span class="mw-headline" id="Miscellaneous"> Miscellaneous </span></h5> 678 + </td></tr> 679 + 680 + <tr class="t-dsc"> 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 + </td> 683 + <td> synchronizes with the underlying storage device <br /> <span class="t-mark">(public member function of <code>std::basic_istream&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 684 + </td></tr> 685 + </table> 686 + <h3> <span class="mw-headline" id="Member_classes">Member classes</span></h3> 687 + <table class="t-dsc-begin"> 688 + 689 + <tr class="t-dsc"> 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 + </td> 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&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 693 + </td></tr> 694 + </table> 695 + </div> 696 + <div class="t-inherited"> 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 + <h3> <span class="mw-headline" id="Member_types_2">Member types</span></h3> 699 + <table class="t-dsc-begin"> 700 + 701 + <tr class="t-dsc-hitem"> 702 + <td> Member type 703 + </td> 704 + <td> Definition 705 + </td></tr> 706 + 707 + 708 + <tr class="t-dsc"> 709 + <td> <code>char_type</code> 710 + </td> 711 + <td> <code>CharT</code> 712 + </td></tr> 713 + 714 + 715 + <tr class="t-dsc"> 716 + <td> <code>traits_type</code> 717 + </td> 718 + <td> <code>Traits</code> 719 + </td></tr> 720 + 721 + 722 + <tr class="t-dsc"> 723 + <td> <code>int_type</code> 724 + </td> 725 + <td> <code>Traits::int_type</code> 726 + </td></tr> 727 + 728 + 729 + <tr class="t-dsc"> 730 + <td> <code>pos_type</code> 731 + </td> 732 + <td> <code>Traits::pos_type</code> 733 + </td></tr> 734 + 735 + 736 + <tr class="t-dsc"> 737 + <td> <code>off_type</code> 738 + </td> 739 + <td> <code>Traits::off_type</code> 740 + </td></tr> 741 + 742 + </table> 743 + <h3> <span class="mw-headline" id="Member_functions_3">Member functions</span></h3> 744 + <table class="t-dsc-begin"> 745 + 746 + <tr> 747 + <td colspan="2"> <h5> <span class="mw-headline" id="State_functions"> State functions </span></h5> 748 + </td></tr> 749 + 750 + <tr class="t-dsc"> 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 + </td> 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&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 754 + </td></tr> 755 + 756 + <tr class="t-dsc"> 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 + </td> 759 + <td> checks if end-of-file has been reached <br /> <span class="t-mark">(public member function of <code>std::basic_ios&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 760 + </td></tr> 761 + 762 + <tr class="t-dsc"> 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 + </td> 765 + <td> checks if an error has occurred <br /> <span class="t-mark">(public member function of <code>std::basic_ios&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 766 + </td></tr> 767 + 768 + <tr class="t-dsc"> 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 + </td> 771 + <td> checks if a non-recoverable error has occurred <br /> <span class="t-mark">(public member function of <code>std::basic_ios&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 772 + </td></tr> 773 + 774 + <tr class="t-dsc"> 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 + </td> 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&lt;CharT,Traits&gt;</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!&amp;action=edit">&#91;edit&#93;</a></span> 778 + </td></tr> 779 + 780 + <tr class="t-dsc"> 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 + </td> 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&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 784 + </td></tr> 785 + 786 + <tr class="t-dsc"> 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 + </td> 789 + <td> returns state flags <br /> <span class="t-mark">(public member function of <code>std::basic_ios&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 790 + </td></tr> 791 + 792 + <tr class="t-dsc"> 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 + </td> 795 + <td> sets state flags <br /> <span class="t-mark">(public member function of <code>std::basic_ios&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 796 + </td></tr> 797 + 798 + <tr class="t-dsc"> 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 + </td> 801 + <td> modifies state flags <br /> <span class="t-mark">(public member function of <code>std::basic_ios&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 802 + </td></tr> 803 + 804 + 805 + <tr> 806 + <td colspan="2"> <h5> <span class="mw-headline" id="Formatting"> Formatting </span></h5> 807 + </td></tr> 808 + 809 + <tr class="t-dsc"> 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 + </td> 812 + <td> copies formatting information <br /> <span class="t-mark">(public member function of <code>std::basic_ios&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 813 + </td></tr> 814 + 815 + <tr class="t-dsc"> 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 + </td> 818 + <td> manages the fill character <br /> <span class="t-mark">(public member function of <code>std::basic_ios&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 819 + </td></tr> 820 + 821 + 822 + <tr> 823 + <td colspan="2"> <h5> <span class="mw-headline" id="Miscellaneous_2"> Miscellaneous </span></h5> 824 + </td></tr> 825 + 826 + <tr class="t-dsc"> 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 + </td> 829 + <td> manages exception mask <br /> <span class="t-mark">(public member function of <code>std::basic_ios&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 830 + </td></tr> 831 + 832 + <tr class="t-dsc"> 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 + </td> 835 + <td> sets the locale <br /> <span class="t-mark">(public member function of <code>std::basic_ios&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 836 + </td></tr> 837 + 838 + <tr class="t-dsc"> 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 + </td> 841 + <td> manages associated stream buffer <br /> <span class="t-mark">(public member function of <code>std::basic_ios&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 842 + </td></tr> 843 + 844 + <tr class="t-dsc"> 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 + </td> 847 + <td> manages tied stream <br /> <span class="t-mark">(public member function of <code>std::basic_ios&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 848 + </td></tr> 849 + 850 + <tr class="t-dsc"> 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 + </td> 853 + <td> narrows characters <br /> <span class="t-mark">(public member function of <code>std::basic_ios&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 854 + </td></tr> 855 + 856 + <tr class="t-dsc"> 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 + </td> 859 + <td> widens characters <br /> <span class="t-mark">(public member function of <code>std::basic_ios&lt;CharT,Traits&gt;</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&amp;action=edit">&#91;edit&#93;</a></span> 860 + </td></tr> 861 + </table> 862 + </div> 863 + <div class="t-inherited"> 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 + <h3> <span class="mw-headline" id="Member_functions_4">Member functions</span></h3> 866 + <table class="t-dsc-begin"> 867 + 868 + 869 + <tr> 870 + <td colspan="2"> <h5> <span class="mw-headline" id="Formatting_2"> Formatting </span></h5> 871 + </td></tr> 872 + 873 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 877 + </td></tr> 878 + 879 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 883 + </td></tr> 884 + 885 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 889 + </td></tr> 890 + 891 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 895 + </td></tr> 896 + 897 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 901 + </td></tr> 902 + 903 + 904 + <tr> 905 + <td colspan="2"> <h5> <span class="mw-headline" id="Locales"> Locales </span></h5> 906 + </td></tr> 907 + 908 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 912 + </td></tr> 913 + 914 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 918 + </td></tr> 919 + 920 + 921 + <tr> 922 + <td colspan="2"> <h5> <span class="mw-headline" id="Internal_extensible_array"> Internal extensible array </span></h5> 923 + </td></tr> 924 + 925 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 929 + </td></tr> 930 + 931 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 935 + </td></tr> 936 + 937 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 941 + </td></tr> 942 + 943 + 944 + <tr> 945 + <td colspan="2"> <h5> <span class="mw-headline" id="Miscellaneous_3"> Miscellaneous </span></h5> 946 + </td></tr> 947 + 948 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 952 + </td></tr> 953 + 954 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 958 + </td></tr> 959 + 960 + 961 + <tr> 962 + <td colspan="2"> <h5> <span class="mw-headline" id="Member_classes_2"> Member classes </span></h5> 963 + </td></tr> 964 + 965 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 969 + </td></tr> 970 + 971 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 975 + </td></tr> 976 + </table> 977 + <table class="t-dsc-begin"> 978 + 979 + <tr> 980 + <td colspan="2"> <h3> <span class="mw-headline" id="Member_types_and_constants"> Member types and constants</span></h3> 981 + </td></tr> 982 + 983 + <tr class="t-dsc-hitem"> 984 + <td> Type 985 + </td> 986 + <td> Explanation 987 + </td></tr> 988 + 989 + 990 + <tr class="t-dsc"> 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 + </td> 993 + <td> stream open mode type 994 + <p>The following constants are also defined: 995 + </p> 996 + <table class="t-dsc-begin"> 997 + 998 + <tr class="t-dsc-hitem"> 999 + <td> Constant 1000 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1002 + </td></tr> 1003 + 1004 + 1005 + <tr class="t-dsc"> 1006 + <td> <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>app</tt></a> 1007 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1009 + </td></tr> 1010 + 1011 + 1012 + <tr class="t-dsc"> 1013 + <td> <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>binary</tt></a> 1014 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1016 + </td></tr> 1017 + 1018 + 1019 + <tr class="t-dsc"> 1020 + <td> <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>in</tt></a> 1021 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1023 + </td></tr> 1024 + 1025 + 1026 + <tr class="t-dsc"> 1027 + <td> <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>out</tt></a> 1028 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1030 + </td></tr> 1031 + 1032 + 1033 + <tr class="t-dsc"> 1034 + <td> <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>trunc</tt></a> 1035 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1037 + </td></tr> 1038 + 1039 + 1040 + <tr class="t-dsc"> 1041 + <td> <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>ate</tt></a> 1042 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1044 + </td></tr> 1045 + 1046 + 1047 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1051 + </td></tr> 1052 + 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&amp;action=edit">&#91;edit&#93;</a></span> 1054 + </td></tr> 1055 + 1056 + <tr class="t-dsc"> 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 + </td> 1059 + <td> formatting flags type 1060 + <p>The following constants are also defined: 1061 + </p> 1062 + <table class="t-dsc-begin"> 1063 + 1064 + <tr class="t-dsc-hitem"> 1065 + <td> Constant 1066 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1068 + </td></tr> 1069 + 1070 + 1071 + <tr class="t-dsc"> 1072 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>dec</tt></a> 1073 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1075 + </td></tr> 1076 + 1077 + 1078 + <tr class="t-dsc"> 1079 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>oct</tt></a> 1080 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1082 + </td></tr> 1083 + 1084 + 1085 + <tr class="t-dsc"> 1086 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>hex</tt></a> 1087 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1089 + </td></tr> 1090 + 1091 + 1092 + <tr class="t-dsc"> 1093 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>basefield</tt></a> 1094 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1096 + </td></tr> 1097 + 1098 + 1099 + <tr class="t-dsc"> 1100 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>left</tt></a> 1101 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1103 + </td></tr> 1104 + 1105 + 1106 + <tr class="t-dsc"> 1107 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>right</tt></a> 1108 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1110 + </td></tr> 1111 + 1112 + 1113 + <tr class="t-dsc"> 1114 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>internal</tt></a> 1115 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1117 + </td></tr> 1118 + 1119 + 1120 + <tr class="t-dsc"> 1121 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>adjustfield</tt></a> 1122 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1124 + </td></tr> 1125 + 1126 + 1127 + <tr class="t-dsc"> 1128 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>scientific</tt></a> 1129 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1131 + </td></tr> 1132 + 1133 + 1134 + <tr class="t-dsc"> 1135 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>fixed</tt></a> 1136 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1138 + </td></tr> 1139 + 1140 + 1141 + <tr class="t-dsc"> 1142 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>floatfield</tt></a> 1143 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1145 + </td></tr> 1146 + 1147 + 1148 + <tr class="t-dsc"> 1149 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>boolalpha</tt></a> 1150 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1152 + </td></tr> 1153 + 1154 + 1155 + <tr class="t-dsc"> 1156 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>showbase</tt></a> 1157 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1159 + </td></tr> 1160 + 1161 + 1162 + <tr class="t-dsc"> 1163 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>showpoint</tt></a> 1164 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1166 + </td></tr> 1167 + 1168 + 1169 + <tr class="t-dsc"> 1170 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>showpos</tt></a> 1171 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1173 + </td></tr> 1174 + 1175 + 1176 + <tr class="t-dsc"> 1177 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>skipws</tt></a> 1178 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1180 + </td></tr> 1181 + 1182 + 1183 + <tr class="t-dsc"> 1184 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>unitbuf</tt></a> 1185 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1187 + </td></tr> 1188 + 1189 + 1190 + <tr class="t-dsc"> 1191 + <td> <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>uppercase</tt></a> 1192 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1194 + </td></tr> 1195 + 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&amp;action=edit">&#91;edit&#93;</a></span> 1197 + </td></tr> 1198 + 1199 + <tr class="t-dsc"> 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 + </td> 1202 + <td> state of the stream type 1203 + <p>The following constants are also defined: 1204 + </p> 1205 + <table class="t-dsc-begin"> 1206 + 1207 + <tr class="t-dsc-hitem"> 1208 + <td> Constant 1209 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1211 + </td></tr> 1212 + 1213 + 1214 + <tr class="t-dsc"> 1215 + <td> <a href="ios_base/iostate.html" title="cpp/io/ios base/iostate"><tt>goodbit</tt></a> 1216 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1218 + </td></tr> 1219 + 1220 + 1221 + <tr class="t-dsc"> 1222 + <td> <a href="ios_base/iostate.html" title="cpp/io/ios base/iostate"><tt>badbit</tt></a> 1223 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1225 + </td></tr> 1226 + 1227 + 1228 + <tr class="t-dsc"> 1229 + <td> <a href="ios_base/iostate.html" title="cpp/io/ios base/iostate"><tt>failbit</tt></a> 1230 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1232 + </td></tr> 1233 + 1234 + 1235 + <tr class="t-dsc"> 1236 + <td> <a href="ios_base/iostate.html" title="cpp/io/ios base/iostate"><tt>eofbit</tt></a> 1237 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1239 + </td></tr> 1240 + 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&amp;action=edit">&#91;edit&#93;</a></span> 1242 + </td></tr> 1243 + 1244 + <tr class="t-dsc"> 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 + </td> 1247 + <td> seeking direction type 1248 + <p>The following constants are also defined: 1249 + </p> 1250 + <table class="t-dsc-begin"> 1251 + 1252 + <tr class="t-dsc-hitem"> 1253 + <td> Constant 1254 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1256 + </td></tr> 1257 + 1258 + 1259 + <tr class="t-dsc"> 1260 + <td> <a href="ios_base/seekdir.html" title="cpp/io/ios base/seekdir"><tt>beg</tt></a> 1261 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1263 + </td></tr> 1264 + 1265 + 1266 + <tr class="t-dsc"> 1267 + <td> <a href="ios_base/seekdir.html" title="cpp/io/ios base/seekdir"><tt>end</tt></a> 1268 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1270 + </td></tr> 1271 + 1272 + 1273 + <tr class="t-dsc"> 1274 + <td> <a href="ios_base/seekdir.html" title="cpp/io/ios base/seekdir"><tt>cur</tt></a> 1275 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1277 + </td></tr> 1278 + 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&amp;action=edit">&#91;edit&#93;</a></span> 1280 + </td></tr> 1281 + 1282 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1286 + </td></tr> 1287 + 1288 + <tr class="t-dsc"> 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 + </td> 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&amp;action=edit">&#91;edit&#93;</a></span> 1292 + </td></tr> 1293 + </table> 1294 + </div> 1295 + <h3><span class="editsection">[<a href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&amp;action=edit&amp;section=3" title="Edit section: Notes">edit</a>]</span> <span class="mw-headline" id="Notes">Notes</span></h3> 1296 + <table class="wikitable ftm-begin ftm-has-value"> 1297 + 1298 + <tr> 1299 + <th><a href="../utility/feature_test.html" title="cpp/utility/feature test">Feature-test</a> macro</th> 1300 + <th>Value</th> 1301 + <th><span title="Standard in which the feature is introduced">Std</span></th> 1302 + <th>Feature 1303 + </th></tr> 1304 + <tr> 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 + <td><span class="mw-geshi cpp source-cpp"><span class="nu0">202306L</span></span></td> 1307 + <td><span class="t-mark">(C++26)</span></td> 1308 + <td>native handles support 1309 + </td></tr></table> 1310 + <h3><span class="editsection">[<a href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&amp;action=edit&amp;section=4" title="Edit section: Example">edit</a>]</span> <span class="mw-headline" id="Example">Example</span></h3> 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 + <div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#include &lt;fstream&gt;</span> 1313 + <span class="co2">#include &lt;iostream&gt;</span> 1314 + <span class="co2">#include &lt;string&gt;</span> 1315 + &#160; 1316 + <span class="kw4">int</span> main<span class="br0">&#40;</span><span class="br0">&#41;</span> 1317 + <span class="br0">&#123;</span> 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">&quot;Test.b&quot;</span><span class="sy4">;</span> 1319 + &#160; 1320 + <span class="co1">// prepare a file to read</span> 1321 + <span class="kw4">double</span> d <span class="sy1">=</span> <span class="nu16">3.14</span><span class="sy4">;</span> 1322 + <a href="basic_ofstream.html"><span class="kw1735">std::<span class="me2">ofstream</span></span></a><span class="br0">&#40;</span>filename, std<span class="sy4">::</span><span class="me2">ios</span><span class="sy4">::</span><span class="me2">binary</span><span class="br0">&#41;</span> 1323 + .<span class="me1">write</span><span class="br0">&#40;</span><span class="kw1">reinterpret_cast</span><span class="sy1">&lt;</span><span class="kw4">char</span><span class="sy2">*</span><span class="sy1">&gt;</span><span class="br0">&#40;</span><span class="sy3">&amp;</span>d<span class="br0">&#41;</span>, sizeof d<span class="br0">&#41;</span> <span class="sy1">&lt;&lt;</span> <span class="nu0">123</span> <span class="sy1">&lt;&lt;</span> <span class="st0">&quot;abc&quot;</span><span class="sy4">;</span> 1324 + &#160; 1325 + <span class="co1">// open file for reading</span> 1326 + std<span class="sy4">::</span><span class="me2">ifstream</span> istrm<span class="br0">&#40;</span>filename, std<span class="sy4">::</span><span class="me2">ios</span><span class="sy4">::</span><span class="me2">binary</span><span class="br0">&#41;</span><span class="sy4">;</span> 1327 + <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy3">!</span>istrm.<span class="me1">is_open</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> 1328 + <a href="cout.html"><span class="kw1759">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">&quot;failed to open &quot;</span> <span class="sy1">&lt;&lt;</span> filename <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span> 1329 + <span class="kw1">else</span> 1330 + <span class="br0">&#123;</span> 1331 + <span class="kw4">double</span> d<span class="sy4">;</span> 1332 + istrm.<span class="me1">read</span><span class="br0">&#40;</span><span class="kw1">reinterpret_cast</span><span class="sy1">&lt;</span><span class="kw4">char</span><span class="sy2">*</span><span class="sy1">&gt;</span><span class="br0">&#40;</span><span class="sy3">&amp;</span>d<span class="br0">&#41;</span>, sizeof d<span class="br0">&#41;</span><span class="sy4">;</span> <span class="co1">// binary input</span> 1333 + <span class="kw4">int</span> n<span class="sy4">;</span> 1334 + <a href="../string/basic_string.html"><span class="kw1233">std::<span class="me2">string</span></span></a> s<span class="sy4">;</span> 1335 + <span class="kw1">if</span> <span class="br0">&#40;</span>istrm <span class="sy1">&gt;&gt;</span> n <span class="sy1">&gt;&gt;</span> s<span class="br0">&#41;</span> <span class="co1">// text input</span> 1336 + <a href="cout.html"><span class="kw1759">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">&quot;read back from file: &quot;</span> <span class="sy1">&lt;&lt;</span> d <span class="sy1">&lt;&lt;</span> <span class="st0">' '</span> <span class="sy1">&lt;&lt;</span> n <span class="sy1">&lt;&lt;</span> <span class="st0">' '</span> <span class="sy1">&lt;&lt;</span> s <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span> 1337 + <span class="br0">&#125;</span> 1338 + <span class="br0">&#125;</span></pre></div></div> 1339 + <p>Output: 1340 + </p> 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 + </div> 1343 + 1344 + <!-- 1345 + NewPP limit report 1346 + Preprocessor visited node count: 17503/1000000 1347 + Preprocessor generated node count: 16854/1000000 1348 + Post‐expand include size: 636886/2097152 bytes 1349 + Template argument size: 178179/2097152 bytes 1350 + Highest expansion depth: 35/40 1351 + Expensive parser function count: 0/100 1352 + --> 1353 + 1354 + <!-- Saved in parser cache with key mwiki1-mwiki_en_:pcache:idhash:494-0!*!0!!en!2!* and timestamp 20231109085046 --> 1355 + </div> <!-- /bodycontent --> 1356 + <!-- printfooter --> 1357 + <div class="printfooter"> 1358 + Retrieved from "<a href="https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&amp;oldid=158179">https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ifstream&amp;oldid=158179</a>" </div> 1359 + <!-- /printfooter --> 1360 + <!-- catlinks --> 1361 + <div id='catlinks' class='catlinks catlinks-allhidden'></div> <!-- /catlinks --> 1362 + <div class="visualClear"></div> 1363 + <!-- debughtml --> 1364 + <!-- /debughtml --> 1365 + </div> 1366 + <!-- /bodyContent --> 1367 + </div> 1368 + </div> 1369 + <!-- /content --> 1370 + <!-- footer --> 1371 + <div id="cpp-footer-base" class="noprint"> 1372 + <div id="footer"> 1373 + <div id="cpp-navigation"> 1374 + <h5>Navigation</h5> 1375 + <ul> 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 + </div> 1378 + <div id="cpp-toolbox"> 1379 + <h5><span>Toolbox</span><a href="basic_ifstream.html#"></a></h5> 1380 + <ul> 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&amp;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&amp;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&amp;action=info">Page information</a></li> </ul> 1382 + </div> 1383 + <div id="cpp-languages"> 1384 + <div><ul><li>In other languages</li></ul></div> 1385 + <div><ul> 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 + </div> 1388 + <ul id="footer-info"> 1389 + <li id="footer-info-lastmod"> This page was last modified on 7 September 2023, at 23:06.</li> 1390 + <li id="footer-info-viewcount">This page has been accessed 1,073,898 times.</li> 1391 + </ul> 1392 + <ul id="footer-places"> 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 + <li id="footer-places-about"><a href="https://en.cppreference.com/w/Cppreference:About" title="Cppreference:About">About cppreference.com</a></li> 1395 + <li id="footer-places-disclaimer"><a href="https://en.cppreference.com/w/Cppreference:General_disclaimer" title="Cppreference:General disclaimer">Disclaimers</a></li> 1396 + </ul> 1397 + <ul id="footer-icons" class="noprint"> 1398 + <li id="footer-poweredbyico"> 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 + </ul> 1401 + <div style="clear:both"> 1402 + </div> 1403 + </div> 1404 + </div> 1405 + <!-- /footer --> 1406 + <script>if(window.mw){ 1407 + mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"}); 1408 + }</script> 1409 + <script src="../../../mwiki/load.php%3Fdebug=false&amp;lang=en&amp;modules=skins.cppreference2&amp;only=scripts&amp;skin=cppreference2&amp;*"></script> 1410 + <script>if(window.mw){ 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 + }</script> 1413 + <script src="../../../mwiki/load.php%3Fdebug=false&amp;lang=en&amp;modules=site&amp;only=scripts&amp;skin=cppreference2&amp;*"></script> 1414 + <script type="text/javascript"> 1415 + var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); 1416 + document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); 1417 + </script> 1418 + <script type="text/javascript"> 1419 + var _gaq = _gaq || []; 1420 + _gaq.push(['_setAccount', 'UA-2828341-1']); 1421 + _gaq.push(['_setDomainName', 'cppreference.com']); 1422 + _gaq.push(['_trackPageview']); 1423 + </script><!-- Served in 6.069 secs. --> 1424 + </body> 1425 + <!-- Cached 20231109085046 --> 1426 + </html>
build/a.out

This is a binary file and will not be displayed.

+214
src/indexer.cpp
··· 1 + #include "indexer.hpp" 2 + #include "prelude.hpp" 3 + #include <cctype> 4 + #include <cstdlib> 5 + 6 + fn filter_divs(std::string_view html) noexcept -> String 7 + { 8 + var buffer = String(); 9 + while (not html.empty()) { 10 + if (html.front() == '<') [[unlikely]] { 11 + while (html.front() != '>') 12 + html.remove_prefix(1); 13 + html.remove_prefix(1); 14 + } else { 15 + buffer += html.front(); 16 + html.remove_prefix(1); 17 + } 18 + } 19 + 20 + return buffer; 21 + } 22 + 23 + fn to_words(std::string_view lines) noexcept -> Vector<String> 24 + { 25 + var buffer = Vector<String>(); 26 + let valid_char = [](Char ch) { 27 + return (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'); 28 + }; 29 + while (not lines.empty()) { 30 + if (not valid_char(lines.front())) [[unlikely]] { 31 + while (not lines.empty() && 32 + not valid_char(lines.front())) { 33 + lines.remove_prefix(1); 34 + } 35 + } else { 36 + var str = String(); 37 + while (valid_char(lines.front())) { 38 + str += std::toupper(lines.front()); 39 + lines.remove_prefix(1); 40 + } 41 + buffer.push_back(str); 42 + } 43 + } 44 + 45 + return buffer; 46 + } 47 + 48 + fn index_directory(std::filesystem::path dir) noexcept -> Vector<Document> 49 + { 50 + std::cout << "creating index of: " << dir << std::endl; 51 + var documents = Vector<Document>(); 52 + for (let& dir_entry : 53 + std::filesystem::recursive_directory_iterator(dir)) { 54 + let path = dir_entry.path(); 55 + if (path.extension() != ".html") 56 + continue; 57 + let document = Document(path.native()); 58 + documents.push_back(document); 59 + } 60 + 61 + return documents; 62 + } 63 + 64 + fn count_query(Ref<const Vector<Document>> documents, 65 + Ref<const String> query) noexcept 66 + -> Vector<std::pair<String, F64>> 67 + { 68 + var matches = Vector<std::pair<String, F64>>(); 69 + for (let& document : documents) { 70 + if (document.freqs.contains(query)) { 71 + matches.push_back( 72 + {document.filename, F64(document.freqs.at(query))}); 73 + } 74 + } 75 + return matches; 76 + } 77 + 78 + fn count_tfidf(Ref<const Vector<Document>> documents, 79 + Ref<const String> query) noexcept 80 + -> Vector<std::pair<String, F64>> 81 + { 82 + var matches = Vector<std::pair<String, F64>>(); 83 + var tf = F64(); 84 + var df = U64(); 85 + for (let& document : documents) { 86 + if (document.freqs.contains(query)) { 87 + tf = F64(document.freqs.at(query)) / 88 + F64(document.freqs.size()); 89 + ++df; 90 + matches.push_back({document.filename, tf}); 91 + } 92 + } 93 + 94 + for (var & [ _, count ] : matches) { 95 + count /= df; 96 + } 97 + return matches; 98 + } 99 + 100 + void cache_index(Ref<const Vector<Document>> documents) noexcept 101 + { 102 + std::cout << "caching index in: "; 103 + using namespace std::filesystem; 104 + /* check if cache dir exists and has an index */ 105 + let cache_dir = get_cache_dir(); 106 + create_directories(cache_dir); 107 + let cache = cache_dir / "cache.txt"s; 108 + 109 + std::cout << cache << std::endl; 110 + 111 + /* index into cache dir */ 112 + var f = std::ofstream(); 113 + if (not exists(cache)) { 114 + f.open(cache.c_str()); 115 + for (let& document : documents) { 116 + f << document.filename << ' ' << document.freqs.size() << '\n'; 117 + for (let& [word, count] : document.freqs) { 118 + f << word << ' ' << count << '\n'; 119 + } 120 + } 121 + f.close(); 122 + } 123 + } 124 + 125 + fn get_cache_dir() noexcept -> std::filesystem::path 126 + { 127 + using namespace std::filesystem; 128 + var cache_dir = String(); 129 + if (std::getenv("XDG_CACHE_HOME")) { 130 + cache_dir = path(std::getenv("XDG_CACHE_HOME")) / "stl-index"; 131 + } else if (std::getenv("HOME")) { 132 + cache_dir = path(std::getenv("HOME")) / ".cache" / "stl-index"; 133 + } else { 134 + cache_dir = path("."); 135 + std::cerr << "Cache directory not found at `$XDG_CACHE_HOME` or `$HOME/.cache`." << std::endl; 136 + std::cerr << "Cache will be dumped in the current directory. Do with it what you will." << std::endl; 137 + } 138 + 139 + return cache_dir; 140 + } 141 + 142 + fn load_index() noexcept -> Vector<Document> 143 + { 144 + std::cout << "loading index from: "; 145 + var documents = Vector<Document>(); 146 + let cache_dir = get_cache_dir(); 147 + var cache = std::ifstream(); 148 + var path = cache_dir / "cache.txt"; 149 + std::cout << path << std::endl; 150 + cache.open(path); 151 + if (cache.is_open()) { 152 + var n = 0ULL; 153 + var count = 0ULL; 154 + while (not cache.eof()) { 155 + var freqs = Vector<std::pair<String, U64>>(); 156 + var filename = String(); 157 + var word = String(); 158 + cache >> filename; 159 + cache >> n; 160 + while (n-- && not cache.eof()) { 161 + cache >> word; 162 + cache >> count; 163 + freqs.push_back({ word, count }); 164 + } 165 + documents.emplace_back(filename, std::unordered_map(freqs.cbegin(), freqs.cend())); 166 + } 167 + } 168 + 169 + return documents; 170 + } 171 + 172 + Document::Document(std::string_view name, map<String, U64>&& mp) 173 + : freqs(mp), filename(name) 174 + { 175 + } 176 + 177 + Document::Document(std::string_view name) : filename(name) 178 + { 179 + var f = std::ifstream(filename); 180 + 181 + if (not f.is_open()) { 182 + std::cout << "Failed to open: " << name << std::endl; 183 + } else { 184 + /* weird notation for converting a file to string */ 185 + var buffer = std::stringstream(); 186 + buffer << f.rdbuf(); 187 + let html = buffer.str(); 188 + 189 + let words = to_words(filter_divs(html)); 190 + for (let& str : words) 191 + ++freqs[str]; 192 + } 193 + } 194 + 195 + void Document::show_freqs() const noexcept 196 + { 197 + for (let & [ term, freq ] : freqs) 198 + std::cout << term << ": " << freq << std::endl; 199 + } 200 + 201 + fn top_n_matches(Ref<const Vector<Document>> documents, Ref<const String> query, U64 n) noexcept 202 + -> Vector<std::pair<String, F64>> 203 + { 204 + var matches = count_tfidf(documents, query); 205 + let greater = [](let& x, let& y) { return x.second > y.second; }; 206 + if (matches.size() < n) 207 + ra::sort(matches, greater); 208 + else 209 + ra::partial_sort(matches, matches.begin() + n, greater); 210 + 211 + matches.resize(n); 212 + 213 + return matches; 214 + }
+45
src/indexer.hpp
··· 1 + #pragma once 2 + #include "prelude.hpp" 3 + #include <filesystem> 4 + #include <fstream> 5 + #include <iostream> 6 + #include <ranges> 7 + #include <sstream> 8 + #include <unordered_map> 9 + 10 + template <typename Key, typename Value> 11 + using map = std::unordered_map<Key, Value>; 12 + 13 + struct Document { 14 + map<String, U64> freqs; 15 + String filename; 16 + 17 + Document(std::string_view name, map<String, U64>&& mp); 18 + 19 + Document(std::string_view name); 20 + 21 + void show_freqs() const noexcept; 22 + }; 23 + 24 + fn filter_divs(std::string_view html) noexcept -> String; 25 + 26 + fn to_words(std::string_view lines) noexcept -> Vector<String>; 27 + 28 + fn index_directory(std::filesystem::path dir) noexcept -> Vector<Document>; 29 + 30 + void cache_index(Ref<const Vector<Document>> documents) noexcept; 31 + 32 + fn load_index() noexcept -> Vector<Document>; 33 + 34 + fn get_cache_dir() noexcept -> std::filesystem::path; 35 + 36 + fn count_query(Ref<const Vector<Document>> documents, 37 + Ref<const String> query) noexcept 38 + -> Vector<std::pair<String, F64>>; 39 + 40 + fn count_tfidf(Ref<const Vector<Document>> documents, 41 + Ref<const String> query) noexcept 42 + -> Vector<std::pair<String, F64>>; 43 + 44 + fn top_n_matches(Ref<const Vector<Document>> documents, Ref<const String> query, U64 n) noexcept 45 + -> Vector<std::pair<String, F64>>;
+52
src/main.cpp
··· 1 + /* ======================================================================== 2 + * 3 + * Filename: main.cpp 4 + * Description: HTML Parser and Browser for cppreference 5 + * Author: Diego A. Estrada Rivera 6 + * Version: 0.0.1 7 + * 8 + * ======================================================================== */ 9 + #include "indexer.hpp" 10 + #include "prelude.hpp" 11 + #include <cctype> 12 + 13 + namespace filesystem = std::filesystem; 14 + 15 + proc Main([[maybe_unused]] std::span<const std::string_view> args) noexcept 16 + -> I32 17 + { 18 + let cppref = 19 + filesystem::path{"/home/Michorron/Git/cppreference-doc/" 20 + "reference/en.cppreference.com"}; 21 + 22 + let cache = get_cache_dir() / "cache.txt"; 23 + var cache_created = exists(cache); 24 + let documents = cache_created ? load_index() : index_directory(cppref) ; 25 + if (not cache_created) cache_index(documents); 26 + 27 + std::cout << "Succesfully indexed " << cppref.filename() << "!" 28 + << std::endl; 29 + 30 + var query = String(); 31 + std::cout << "What is your query?\nType here: "; 32 + std::getline(std::cin, query); 33 + 34 + cache_index(documents); 35 + 36 + let greater = [](let& x, let& y) { return x.second > y.second; }; 37 + 38 + for (var& c : query) c = std::toupper(c); 39 + var matches = count_tfidf(documents, query); 40 + if (matches.size() < 5) 41 + ra::sort(matches, greater); 42 + else 43 + ra::partial_sort(matches, matches.begin() + 5, greater); 44 + 45 + for (var idx = 0LLU; let & [ name, score ] : matches) { 46 + if (idx > 5) 47 + break; 48 + std::cout << name << " had " << score << " score.\n"; 49 + ++idx; 50 + } 51 + return 0; 52 + }
+48
src/prelude.cpp
··· 1 + /* ======================================================================== 2 + * 3 + * Filename: prelude.hpp 4 + * Description: C++ sensible prelude - Definitions 5 + * Author: Diego A. Estrada Rivera 6 + * Version: 0.0.4 7 + * 8 + * ======================================================================== */ 9 + #include "prelude.hpp" 10 + #include <ranges> 11 + 12 + /* type-safe main */ 13 + I32 main(const I32 argc, const Handle<const CString> argv) 14 + { 15 + proc Main(std::span<const std::string_view>) noexcept -> I32; 16 + let args = std::vector<std::string_view>( 17 + argv, std::next(argv, static_cast<std::ptrdiff_t>(argc))); 18 + return Main(args); 19 + } 20 + 21 + /* Sensible IO */ 22 + #include <iostream> 23 + 24 + proc getLine() noexcept -> String 25 + { 26 + var str = String(); 27 + getline(std::cin, str); 28 + return str; 29 + } 30 + 31 + proc getChar() noexcept -> Char 32 + { 33 + var c = Char(); 34 + std::cin >> c; 35 + return c; 36 + } 37 + 38 + proc print(const std::string_view& f) noexcept -> Unit 39 + { 40 + std::cout << f; 41 + return Unit(); 42 + } 43 + 44 + proc println(const std::string_view& f) noexcept -> Unit 45 + { 46 + std::cout << f << std::endl; 47 + return Unit(); 48 + }
+141
src/prelude.hpp
··· 1 + /* ======================================================================== 2 + * 3 + * Filename: prelude.hpp 4 + * Description: C++ sensible prelude - Declarations 5 + * Author: Diego A. Estrada Rivera 6 + * Version: 0.0.4 7 + * 8 + * ======================================================================== */ 9 + #pragma once 10 + 11 + /* === Generic includes === */ 12 + #include <list> 13 + 14 + #include <queue> 15 + #include <span> 16 + #include <stack> 17 + #include <unordered_map> 18 + #include <unordered_set> 19 + 20 + #include <algorithm> 21 + #include <numeric> 22 + #include <ranges> 23 + 24 + #include <format> 25 + #include <fstream> 26 + 27 + /* === Numeric Types === */ 28 + #include <cstdint> 29 + #include <limits.h> 30 + using Size = std::size_t; 31 + 32 + /* Floating Point */ 33 + // brain floating point 34 + // see https://en.wikipedia.org/wiki/Bfloat16_floating-point_format 35 + typedef __bf16 BF16; 36 + typedef _Float16 F16; 37 + typedef float F32; 38 + static_assert(sizeof(F32) * CHAR_BIT == 32); // 39 + typedef double F64; 40 + static_assert(sizeof(F64) * CHAR_BIT == 64); 41 + #if __float80_max < __float128_max 42 + typedef __float80 F80; // sometimes is the same as F128 43 + #endif 44 + typedef __float128 F128; 45 + 46 + // decimal floating points 47 + // see decimal32/64/128 in https://en.wikipedia.org/wiki/IEEE_754 48 + #if 0 49 + typedef float __attribute__((mode(SD))) D32; 50 + typedef float __attribute__((mode(DD))) D64; 51 + typedef float __attribute__((mode(TD))) D128; 52 + #endif 53 + 54 + /* Integer */ 55 + typedef uint8_t U8; 56 + typedef uint16_t U16; 57 + typedef uint32_t U32; 58 + typedef uint64_t U64; 59 + typedef __uint128_t U128; 60 + 61 + typedef int8_t I8; 62 + typedef int16_t I16; 63 + typedef int32_t I32; 64 + typedef int64_t I64; 65 + typedef __int128_t I128; 66 + 67 + // generic Integer type 68 + typedef int_fast32_t Int; 69 + 70 + /* === Other Types === */ 71 + typedef bool Bool; 72 + typedef char Char; 73 + typedef const char* CString; 74 + 75 + #include <vector> 76 + template <typename T> using Vector = std::vector<T>; 77 + 78 + #include <string> 79 + using String = std::string; 80 + using namespace std::string_literals; 81 + 82 + namespace ra = std::ranges; 83 + namespace vi = std::ranges::views; 84 + 85 + // Unit type 86 + enum class Unit { unit }; 87 + 88 + // Void type 89 + enum class Void {}; 90 + 91 + // Pointer types 92 + template <typename T> using Ref = T&; 93 + 94 + template <typename T> using Handle = T*; 95 + 96 + /* === Keywords === */ 97 + #define let auto const 98 + #define var auto 99 + #define fn [[nodiscard, gnu::const]] auto 100 + #define proc [[nodiscard]] auto 101 + 102 + /* This is included as a static member variable of <tuple>. 103 + * However, there is no way to bring the std::ignore namespace static variable 104 + * into the current scope. This is a way to do that. 105 + * https://en.cppreference.com/w/cpp/utility/tuple/ignore 106 + */ 107 + namespace detail { 108 + struct ignore_t { 109 + template <typename T> 110 + constexpr // required since C++14 111 + void 112 + operator=(T&&) const noexcept 113 + { 114 + } 115 + }; 116 + } // namespace detail 117 + inline constinit const detail::ignore_t ignore; // changed to constinit 118 + 119 + // manage tuples better 120 + #define fst std::get<0> 121 + #define snd std::get<1> 122 + #define thr std::get<2> 123 + 124 + /* === Miscellaneous Functions */ 125 + template <class D, class C> fn memoize(let& op) noexcept 126 + { 127 + static var mp = std::unordered_map<D, C>(); 128 + return [=](D const& x) noexcept { 129 + return mp.contains(x) ? mp.at(x) : mp[x] = op(x); 130 + }; 131 + } 132 + 133 + /* Sensible IO */ 134 + #include <iostream> 135 + proc getLine() noexcept -> String; 136 + 137 + proc getChar() noexcept -> Char; 138 + 139 + proc print(const std::string_view& f) noexcept -> Unit; 140 + 141 + proc println(const std::string_view& f) noexcept -> Unit;