<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.15"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>libstdc++: std::basic_ostream< _CharT, _Traits >::sentry Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript" src="navtreedata.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(document).ready(initResizable); /* @license-end */</script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">libstdc++ </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.15 --> </div><!-- top --> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> <div id="nav-sync" class="sync"></div> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(document).ready(function(){initNavTree('a02640.html','');}); /* @license-end */ </script> <div id="doc-content"> <div class="header"> <div class="summary"> <a href="#pub-methods">Public Member Functions</a> | <a href="a02637.html">List of all members</a> </div> <div class="headertitle"> <div class="title">std::basic_ostream< _CharT, _Traits >::sentry Class Reference</div> </div> </div><!--header--> <div class="contents"> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a> Public Member Functions</h2></td></tr> <tr class="memitem:ae972dd47564726ff41e6be700820719c"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="a02640.html#ae972dd47564726ff41e6be700820719c">sentry</a> (<a class="el" href="a02460.html">basic_ostream</a>< _CharT, _Traits > &__os)</td></tr> <tr class="separator:ae972dd47564726ff41e6be700820719c"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a33286f6402b3651e04c6cfc4b8e719f1"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="a02640.html#a33286f6402b3651e04c6cfc4b8e719f1">~sentry</a> ()</td></tr> <tr class="separator:a33286f6402b3651e04c6cfc4b8e719f1"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:afb51ae0eb2883c81ff22e810e891be9f"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="a02640.html#afb51ae0eb2883c81ff22e810e891be9f">operator bool</a> () const</td></tr> <tr class="separator:afb51ae0eb2883c81ff22e810e891be9f"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"><h3>template<typename _CharT, typename _Traits><br /> class std::basic_ostream< _CharT, _Traits >::sentry</h3> <p>Performs setup work for output streams. </p> <p>Objects of this class are created before all of the standard inserters are run. It is responsible for <em>exception-safe prefix and suffix operations</em>. </p> <p class="definition">Definition at line <a class="el" href="a00116_source.html#l00426">426</a> of file <a class="el" href="a00116_source.html">ostream</a>.</p> </div><h2 class="groupheader">Constructor & Destructor Documentation</h2> <a id="ae972dd47564726ff41e6be700820719c"></a> <h2 class="memtitle"><span class="permalink"><a href="#ae972dd47564726ff41e6be700820719c">◆ </a></span>sentry()</h2> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _CharT, typename _Traits> </div> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname"><a class="el" href="a02460.html">std::basic_ostream</a>< _CharT, _Traits >::sentry::sentry </td> <td>(</td> <td class="paramtype"><a class="el" href="a02460.html">basic_ostream</a>< _CharT, _Traits > & </td> <td class="paramname"><em>__os</em></td><td>)</td> <td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">explicit</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>The constructor performs preparatory work. </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">__os</td><td>The output stream to guard.</td></tr> </table> </dd> </dl> <p>If the stream state is good (<em>__os.good()</em> is true), then if the stream is tied to another output stream, <code>is.tie()->flush()</code> is called to synchronize the output sequences.</p> <p>If the stream state is still good, then the sentry state becomes true (<em>okay</em>). </p> <p class="definition">Definition at line <a class="el" href="a00431_source.html#l00047">47</a> of file <a class="el" href="a00431_source.html">ostream.tcc</a>.</p> <p class="reference">References <a class="el" href="a00383_source.html#l00410">std::ios_base::failbit</a>, <a class="el" href="a00284_source.html#l00180">std::basic_ios< _CharT, _Traits >::good()</a>, <a class="el" href="a00284_source.html#l00157">std::basic_ios< _CharT, _Traits >::setstate()</a>, and <a class="el" href="a00284_source.html#l00295">std::basic_ios< _CharT, _Traits >::tie()</a>.</p> </div> </div> <a id="a33286f6402b3651e04c6cfc4b8e719f1"></a> <h2 class="memtitle"><span class="permalink"><a href="#a33286f6402b3651e04c6cfc4b8e719f1">◆ </a></span>~sentry()</h2> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _CharT, typename _Traits> </div> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname"><a class="el" href="a02460.html">std::basic_ostream</a>< _CharT, _Traits >::sentry::~sentry </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">inline</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Possibly flushes the stream. </p> <p>If <code>ios_base::unitbuf</code> is set in <code>os.flags()</code>, and <code>std::uncaught_exception()</code> is true, the sentry destructor calls <code>flush()</code> on the output stream. </p> <p class="definition">Definition at line <a class="el" href="a00116_source.html#l00456">456</a> of file <a class="el" href="a00116_source.html">ostream</a>.</p> <p class="reference">References <a class="el" href="a00383_source.html#l00402">std::ios_base::badbit</a>, <a class="el" href="a01538.html#a8198e6da55875b63c2c10ca60a2514ec">std::uncaught_exception()</a>, and <a class="el" href="a00383_source.html#l00371">std::ios_base::unitbuf</a>.</p> </div> </div> <h2 class="groupheader">Member Function Documentation</h2> <a id="afb51ae0eb2883c81ff22e810e891be9f"></a> <h2 class="memtitle"><span class="permalink"><a href="#afb51ae0eb2883c81ff22e810e891be9f">◆ </a></span>operator bool()</h2> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _CharT, typename _Traits> </div> <table class="mlabels"> <tr> <td class="mlabels-left"> <table class="memname"> <tr> <td class="memname"><a class="el" href="a02460.html">std::basic_ostream</a>< _CharT, _Traits >::sentry::operator bool </td> <td>(</td> <td class="paramname"></td><td>)</td> <td> const</td> </tr> </table> </td> <td class="mlabels-right"> <span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">explicit</span></span> </td> </tr> </table> </div><div class="memdoc"> <p>Quick status checking. </p> <dl class="section return"><dt>Returns</dt><dd>The sentry state.</dd></dl> <p>For ease of use, sentries may be converted to booleans. The return value is that of the sentry state (true == okay). </p> <p class="definition">Definition at line <a class="el" href="a00116_source.html#l00478">478</a> of file <a class="el" href="a00116_source.html">ostream</a>.</p> </div> </div> <hr/>The documentation for this class was generated from the following files:<ul> <li><a class="el" href="a00116_source.html">ostream</a></li> <li><a class="el" href="a00431_source.html">ostream.tcc</a></li> </ul> </div><!-- contents --> </div><!-- doc-content --> <!-- start footer part --> <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> <ul> <li class="navelem"><a class="el" href="a01538.html">std</a></li><li class="navelem"><a class="el" href="a02460.html">basic_ostream</a></li><li class="navelem"><a class="el" href="a02640.html">sentry</a></li> <li class="footer">Generated by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.15 </li> </ul> </div> </body> </html>