diff options
Diffstat (limited to 'doc/html/tribool')
-rw-r--r-- | doc/html/tribool/reference.html | 113 | ||||
-rw-r--r-- | doc/html/tribool/tests.html | 80 | ||||
-rw-r--r-- | doc/html/tribool/tutorial.html | 181 |
3 files changed, 374 insertions, 0 deletions
diff --git a/doc/html/tribool/reference.html b/doc/html/tribool/reference.html new file mode 100644 index 0000000000..fe234a1656 --- /dev/null +++ b/doc/html/tribool/reference.html @@ -0,0 +1,113 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>Reference</title> +<link rel="stylesheet" href="../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.68.1"> +<link rel="start" href="../index.html" title="The Boost C++ Libraries"> +<link rel="up" href="../tribool.html" title="Chapter 13. Boost.Tribool"> +<link rel="prev" href="tutorial.html" title="Tutorial"> +<link rel="next" href="../boost/logic/tribool.html" title="Class tribool"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"> +<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.htm">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="../../../people/people.htm">People</a></td> +<td align="center"><a href="../../../more/faq.htm">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="tutorial.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../tribool.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="../boost/logic/tribool.html"><img src="../images/next.png" alt="Next"></a> +</div> +<div class="section" lang="en"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="tribool.reference"></a>Reference</h3></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="reference.html#id996838">Header <boost/logic/tribool.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#id1277326">Header <boost/logic/tribool_fwd.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#id1277344">Header <boost/logic/tribool_io.hpp></a></span></dt> +</dl></div> +<div class="section" lang="en"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="id996838"></a>Header <<a href="../../../boost/logic/tribool.hpp" target="_top">boost/logic/tribool.hpp</a>></h4></div></div></div> +<pre class="synopsis"> + +<a href="../BOOST_TRIBOOL_THIRD_STATE.html" title="Macro BOOST_TRIBOOL_THIRD_STATE">BOOST_TRIBOOL_THIRD_STATE</a>(Name)</pre> +<pre class="synopsis"><span class="bold"><strong>namespace</strong></span> boost { + <span class="bold"><strong>namespace</strong></span> logic { + <span class="bold"><strong>class</strong></span> <a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>; + <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="../indeterminate.html" title="Function indeterminate">indeterminate</a>(<a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>, <span class="emphasis"><em>unspecified</em></span> = <span class="emphasis"><em>unspecified</em></span>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id866049.html" title="Function operator!"><span class="bold"><strong>operator</strong></span>!</a>(<a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id1081555.html" title="Function operator&&"><span class="bold"><strong>operator</strong></span>&&</a>(<a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>, <a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id1081555.html" title="Function operator&&"><span class="bold"><strong>operator</strong></span>&&</a>(<a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>, <span class="bold"><strong>bool</strong></span>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id1081555.html" title="Function operator&&"><span class="bold"><strong>operator</strong></span>&&</a>(<span class="bold"><strong>bool</strong></span>, <a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id1081555.html" title="Function operator&&"><span class="bold"><strong>operator</strong></span>&&</a>(indeterminate_keyword_t, <a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id1081555.html" title="Function operator&&"><span class="bold"><strong>operator</strong></span>&&</a>(<a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>, indeterminate_keyword_t); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id791859.html" title="Function operator||"><span class="bold"><strong>operator</strong></span>||</a>(<a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>, <a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id791859.html" title="Function operator||"><span class="bold"><strong>operator</strong></span>||</a>(<a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>, <span class="bold"><strong>bool</strong></span>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id791859.html" title="Function operator||"><span class="bold"><strong>operator</strong></span>||</a>(<span class="bold"><strong>bool</strong></span>, <a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id791859.html" title="Function operator||"><span class="bold"><strong>operator</strong></span>||</a>(indeterminate_keyword_t, <a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id791859.html" title="Function operator||"><span class="bold"><strong>operator</strong></span>||</a>(<a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>, indeterminate_keyword_t); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id935001.html" title="Function operator=="><span class="bold"><strong>operator</strong></span>==</a>(<a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>, <a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id935001.html" title="Function operator=="><span class="bold"><strong>operator</strong></span>==</a>(<a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>, <span class="bold"><strong>bool</strong></span>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id935001.html" title="Function operator=="><span class="bold"><strong>operator</strong></span>==</a>(<span class="bold"><strong>bool</strong></span>, <a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id935001.html" title="Function operator=="><span class="bold"><strong>operator</strong></span>==</a>(indeterminate_keyword_t, <a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id935001.html" title="Function operator=="><span class="bold"><strong>operator</strong></span>==</a>(<a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>, indeterminate_keyword_t); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id1222476.html" title="Function operator!="><span class="bold"><strong>operator</strong></span>!=</a>(<a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>, <a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id1222476.html" title="Function operator!="><span class="bold"><strong>operator</strong></span>!=</a>(<a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>, <span class="bold"><strong>bool</strong></span>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id1222476.html" title="Function operator!="><span class="bold"><strong>operator</strong></span>!=</a>(<span class="bold"><strong>bool</strong></span>, <a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id1222476.html" title="Function operator!="><span class="bold"><strong>operator</strong></span>!=</a>(indeterminate_keyword_t, <a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>); + <span class="type"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></span> <a href="../id1222476.html" title="Function operator!="><span class="bold"><strong>operator</strong></span>!=</a>(<a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>, indeterminate_keyword_t); + } +}</pre> +</div> +<div class="section" lang="en"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="id1277326"></a>Header <<a href="../../../boost/logic/tribool_fwd.hpp" target="_top">boost/logic/tribool_fwd.hpp</a>></h4></div></div></div> +<pre class="synopsis"><span class="bold"><strong>namespace</strong></span> boost { + <span class="bold"><strong>namespace</strong></span> logic { + } +}</pre> +</div> +<div class="section" lang="en"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="id1277344"></a>Header <<a href="../../../boost/logic/tribool_io.hpp" target="_top">boost/logic/tribool_io.hpp</a>></h4></div></div></div> +<pre class="synopsis"><span class="bold"><strong>namespace</strong></span> boost { + <span class="bold"><strong>namespace</strong></span> logic { + <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> CharT> <span class="bold"><strong>class</strong></span> <a href="../indeterminate_name.html" title="Class template indeterminate_name">indeterminate_name</a>; + <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> T> + <span class="type">std::basic_string< T ></span> <a href="../id1244293.html" title="Function template get_default_indeterminate_name">get_default_indeterminate_name</a>(); + + <span class="emphasis"><em>// Returns the character string "indeterminate". </em></span> + <span class="bold"><strong>template</strong></span><> + <span class="type">std::basic_string< <span class="bold"><strong>char</strong></span> ></span> <a name="id894358"></a>get_default_indeterminate_name<<span class="bold"><strong>char</strong></span> >(); + + <span class="emphasis"><em>// Returns the wide character string L"indeterminate". </em></span> + <span class="bold"><strong>template</strong></span><> + <span class="type">std::basic_string< <span class="bold"><strong>wchar_t</strong></span> ></span> <a name="id1245131"></a>get_default_indeterminate_name<<span class="bold"><strong>wchar_t</strong></span> >(); + <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> CharT, <span class="bold"><strong>typename</strong></span> Traits> + <span class="type">std::basic_ostream< CharT, Traits > &</span> + <a href="../id1245151.html" title="Function template operator<<"><span class="bold"><strong>operator</strong></span><<</a>(std::basic_ostream< CharT, Traits > &, <a href="../boost/logic/tribool.html" title="Class tribool">tribool</a>); + <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> CharT, <span class="bold"><strong>typename</strong></span> Traits> + <span class="type">std::basic_ostream< CharT, Traits > &</span> + <a href="../id1286986.html" title="Function template operator<<"><span class="bold"><strong>operator</strong></span><<</a>(std::basic_ostream< CharT, Traits > &, <span class="emphasis"><em>unspecified</em></span>); + <span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> CharT, <span class="bold"><strong>typename</strong></span> Traits> + <span class="type">std::basic_istream< CharT, Traits > &</span> + <a href="../id1287075.html" title="Function template operator>>"><span class="bold"><strong>operator</strong></span>>></a>(std::basic_istream< CharT, Traits > &, <a href="../boost/logic/tribool.html" title="Class tribool">tribool</a> &); + } +}</pre> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><small>Copyright © 2002-2004 Douglas Gregor</small></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="tutorial.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../tribool.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="../boost/logic/tribool.html"><img src="../images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/tribool/tests.html b/doc/html/tribool/tests.html new file mode 100644 index 0000000000..9c91b254b4 --- /dev/null +++ b/doc/html/tribool/tests.html @@ -0,0 +1,80 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>Testsuite</title> +<link rel="stylesheet" href="../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.68.1"> +<link rel="start" href="../index.html" title="The Boost C++ Libraries"> +<link rel="up" href="../tribool.html" title="Chapter 13. Boost.Tribool"> +<link rel="prev" href="../id1287075.html" title="Function template operator>>"> +<link rel="next" href="../boost_typetraits.html" title="Chapter 14. Boost.TypeTraits"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"> +<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.htm">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="../../../people/people.htm">People</a></td> +<td align="center"><a href="../../../more/faq.htm">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../id1287075.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../tribool.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="../boost_typetraits.html"><img src="../images/next.png" alt="Next"></a> +</div> +<div class="section" lang="en"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="tribool.tests"></a>Testsuite</h3></div></div></div> +<div class="toc"><dl><dt><span class="section"><a href="tests.html#tribool.tests.acceptance">Acceptance tests</a></span></dt></dl></div> +<div class="section" lang="en"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="tribool.tests.acceptance"></a>Acceptance tests</h4></div></div></div> +<div class="informaltable"><table class="table"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th>Test</th> +<th>Type</th> +<th>Description</th> +<th>If failing...</th> +</tr></thead> +<tbody> +<tr> +<td><p><a href="../../../libs/logic/test/tribool_test.cpp" target="_top">tribool_test.cpp</a></p></td> +<td><p>run</p></td> +<td><p>Test all features of the + <code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">boost::logic::tribool</a></code> + class.</p></td> +<td> </td> +</tr> +<tr> +<td><p><a href="../../../libs/logic/test/tribool_rename_test.cpp" target="_top">tribool_rename_test.cpp</a></p></td> +<td><p>run</p></td> +<td><p>Test the use of the + <code class="computeroutput"><a href="../BOOST_TRIBOOL_THIRD_STATE.html" title="Macro BOOST_TRIBOOL_THIRD_STATE">BOOST_TRIBOOL_THIRD_STATE</a></code> + macro.</p></td> +<td> </td> +</tr> +<tr> +<td><p><a href="../../../libs/logic/test/tribool_io_test.cpp" target="_top">tribool_io_test.cpp</a></p></td> +<td><p>run</p></td> +<td><p>Test tribool input/output.</p></td> +<td> </td> +</tr> +</tbody> +</table></div> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><small>Copyright © 2002-2004 Douglas Gregor</small></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../id1287075.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../tribool.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="../boost_typetraits.html"><img src="../images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/tribool/tutorial.html b/doc/html/tribool/tutorial.html new file mode 100644 index 0000000000..9b58de387b --- /dev/null +++ b/doc/html/tribool/tutorial.html @@ -0,0 +1,181 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>Tutorial</title> +<link rel="stylesheet" href="../boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.68.1"> +<link rel="start" href="../index.html" title="The Boost C++ Libraries"> +<link rel="up" href="../tribool.html" title="Chapter 13. Boost.Tribool"> +<link rel="prev" href="../tribool.html" title="Chapter 13. Boost.Tribool"> +<link rel="next" href="reference.html" title="Reference"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"> +<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.htm">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="../../../people/people.htm">People</a></td> +<td align="center"><a href="../../../more/faq.htm">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../tribool.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../tribool.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="reference.html"><img src="../images/next.png" alt="Next"></a> +</div> +<div class="section" lang="en"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="tribool.tutorial"></a>Tutorial</h3></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="tutorial.html#id1567990">Basic usage</a></span></dt> +<dt><span class="section"><a href="tutorial.html#id1568440">Renaming the indeterminate state</a></span></dt> +<dt><span class="section"><a href="tutorial.html#id1568520"><code class="computeroutput">tribool</code> input/output</a></span></dt> +</dl></div> +<div class="section" lang="en"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="id1567990"></a>Basic usage</h4></div></div></div> +<p> The <code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> class acts + like the built-in <code class="computeroutput">bool</code> type, but for 3-state boolean + logic. The three states are <code class="computeroutput">true</code>, <code class="computeroutput">false</code>, + and <code class="computeroutput"><a href="../indeterminate.html" title="Function indeterminate">indeterminate</a></code>, where + the first two states are equivalent to those of the C++ + <code class="computeroutput">bool</code> type and the last state represents an unknown + boolean value (that may be <code class="computeroutput">true</code> or + <code class="computeroutput">false</code>, we don't know).</p> +<p> The <code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> class + supports conversion from <code class="computeroutput">bool</code> values and literals + along with its own + <code class="computeroutput"><a href="../indeterminate.html" title="Function indeterminate">indeterminate</a></code> + keyword:</p> +<pre class="programlisting"><code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> b(true); +b = false; +b = <code class="computeroutput"><a href="../indeterminate.html" title="Function indeterminate">indeterminate</a></code>; +<code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> b2(b);</pre> +<p><code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> supports + conversions to <code class="computeroutput">bool</code> for use in conditional + statements. The conversion to <code class="computeroutput">bool</code> will be + <code class="computeroutput">true</code> when the value of the + <code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> is always true, and + <code class="computeroutput">false</code> otherwise. Consequently, the following idiom + may be used to determine which of the three states a + <code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> currently + holds:</p> +<pre class="programlisting"><code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> b = some_operation(); +if (b) { + // b is true +} +else if (!b) { + // b is false +} +else { + // b is indeterminate +}</pre> +<p><code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> supports the + 3-state logic operators <code class="computeroutput">!</code> (negation), + <code class="computeroutput">&&</code> (AND), and <code class="computeroutput">||</code> (OR), with + <code class="computeroutput">bool</code> and <code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> + values. For instance:</p> +<pre class="programlisting"><code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> x = some_op(); +<code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> y = some_other_op(); +if (x && y) { + // both x and y are true +} +else if (!(x && y)) { + // either x or y is false +} +else { + // neither x nor y is false, but we don't know that both are true + + if (x || y) { + // either x or y is true + } +}</pre> +<p> Similarly, <code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> + supports 3-state equality comparisons via the operators + <code class="computeroutput">==</code> and <code class="computeroutput">!=</code>. These operators differ from + "normal" equality operators in C++ because they return a + <code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code>, because potentially we + might not know the result of a comparison (try to compare + <code class="computeroutput">true</code> and + <code class="computeroutput"><a href="../indeterminate.html" title="Function indeterminate">indeterminate</a></code>). For + instance:</p> +<pre class="programlisting"><code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> x(true); +<code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> y(<code class="computeroutput"><a href="../indeterminate.html" title="Function indeterminate">indeterminate</a></code>); + +assert(x == x); // okay, x == x returns true +assert(x == true); // okay, can compare <code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code>s and bools</pre> +<p> The <code class="computeroutput"><a href="../indeterminate.html" title="Function indeterminate">indeterminate</a></code> keyword (representing the + <code class="computeroutput"><a href="../indeterminate.html" title="Function indeterminate">indeterminate</a></code> <code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> value) + doubles as a function to check if the value of a + <code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> is indeterminate, + e.g.,</p> +<pre class="programlisting"><code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> x = try_to_do_something_tricky(); +if (<code class="computeroutput"><a href="../indeterminate.html" title="Function indeterminate">indeterminate</a></code>(x)) { + // value of x is indeterminate +} +else { + // report success or failure of x +}</pre> +</div> +<div class="section" lang="en"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="id1568440"></a>Renaming the indeterminate state</h4></div></div></div> +<p> Users may introduce additional keywords for the indeterminate + value in addition to the implementation-supplied + <code class="computeroutput"><a href="../indeterminate.html" title="Function indeterminate">indeterminate</a></code> using the + <code class="computeroutput"><a href="../BOOST_TRIBOOL_THIRD_STATE.html" title="Macro BOOST_TRIBOOL_THIRD_STATE">BOOST_TRIBOOL_THIRD_STATE</a></code> + macro. For instance, the following macro instantiation (at the + global scope) will introduce the keyword <code class="computeroutput">maybe</code> as a + synonym for <code class="computeroutput"><a href="../indeterminate.html" title="Function indeterminate">indeterminate</a></code> + (also residing in the <code class="computeroutput">boost</code> namespace):</p> +<pre class="programlisting"><code class="computeroutput"><a href="../BOOST_TRIBOOL_THIRD_STATE.html" title="Macro BOOST_TRIBOOL_THIRD_STATE">BOOST_TRIBOOL_THIRD_STATE</a></code>(maybe) +<code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> x = maybe; +if (maybe(x)) { /* ... */ }</pre> +</div> +<div class="section" lang="en"> +<div class="titlepage"><div><div><h4 class="title"> +<a name="id1568520"></a><code class="computeroutput">tribool</code> input/output</h4></div></div></div> +<p><code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> objects may be + read from and written to streams by including the + <code class="computeroutput"><a href="reference.html#id1277344" title="Header <boost/logic/tribool_io.hpp>">boost/logic/tribool_io.hpp</a></code> header in a + manner very similar to <code class="computeroutput">bool</code> values. When the + <code class="computeroutput">boolalpha</code> flag is not set on the input/output stream, + the integral values 0, 1, and 2 correspond to <code class="computeroutput">tribool</code> + values <code class="computeroutput">false</code>, <code class="computeroutput">true</code>, and + <code class="computeroutput">indeterminate</code>, respectively. When + <code class="computeroutput">boolalpha</code> is set on the stream, arbitrary strings can + be used to represent the three values, the default being "false", + "true", and "indeterminate". For instance:</p> +<pre class="programlisting"><code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> x; +cin >> x; // Type "0", "1", or "2" to get false, true, or indeterminate +cout << boolalpha << x; // Produces "false", "true", or "indeterminate"</pre> +<p><code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> input and output + is sensitive to the stream's current locale. The strings associated + with false and true values are contained in the standard + <code class="computeroutput">std::numpunct</code> facet, and the + string naming the indeterminate type is contained in the + <code class="computeroutput"><a href="../indeterminate_name.html" title="Class template indeterminate_name">indeterminate_name</a></code> facet. To + replace the name of the indeterminate state, you need to imbue your + stream with a local containing a + <code class="computeroutput"><a href="../indeterminate_name.html" title="Class template indeterminate_name">indeterminate_name</a></code> facet, e.g.:</p> +<pre class="programlisting"><code class="computeroutput"><a href="../BOOST_TRIBOOL_THIRD_STATE.html" title="Macro BOOST_TRIBOOL_THIRD_STATE">BOOST_TRIBOOL_THIRD_STATE</a></code>(maybe) +locale global; +locale test_locale(global, new <code class="computeroutput"><a href="../indeterminate_name.html" title="Class template indeterminate_name">indeterminate_name</a></code><char>("maybe")); +cout.imbue(test_locale); +<code class="computeroutput"><a href="../boost/logic/tribool.html" title="Class tribool">tribool</a></code> x(maybe); +cout << boolalpha << x << endl; // Prints "maybe"</pre> +<p>If you C++ standard library implementation does not support + locales, <code class="computeroutput">tribool</code> input/output will still work, but you + will be unable to customize the strings printed/parsed when + <code class="computeroutput">boolalpha</code> is set.</p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><small>Copyright © 2002-2004 Douglas Gregor</small></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../tribool.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../tribool.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="reference.html"><img src="../images/next.png" alt="Next"></a> +</div> +</body> +</html> |