File: a00022.html

package info (click to toggle)
libloki 0.1.7-5
  • links: PTS
  • area: main
  • in suites: bookworm, trixie
  • size: 6,600 kB
  • sloc: cpp: 30,475; ansic: 1,974; makefile: 365; php: 316; perl: 108
file content (105 lines) | stat: -rwxr-xr-x 8,029 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Loki: Loki::CheckReturn&lt; Value, OnError &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    <li>
      <form action="search.php" method="get">
        <table cellspacing="0" cellpadding="0" border="0">
          <tr>
            <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td>
            <td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
          </tr>
        </table>
      </form>
    </li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
      <li><a href="classes.html"><span>Class&nbsp;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="a00192.html">Loki</a>::<a class="el" href="a00022.html">CheckReturn</a>
  </div>
</div>
<div class="contents">
<h1>Loki::CheckReturn&lt; Value, OnError &gt; Class Template Reference</h1><!-- doxytag: class="Loki::CheckReturn" --><code>#include &lt;CheckReturn.h&gt;</code>
<p>

<p>
<a href="a00305.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="9e250eb61af69adaee7773a79400a6f7"></a><!-- doxytag: member="Loki::CheckReturn::CheckReturn" ref="9e250eb61af69adaee7773a79400a6f7" args="(const Value &amp;value)" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00022.html#9e250eb61af69adaee7773a79400a6f7">CheckReturn</a> (const Value &amp;value)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Conversion constructor changes Value type to <a class="el" href="a00022.html">CheckReturn</a> type. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00022.html#c25f0d90452244c84dafbb23c5cdb012">CheckReturn</a> (const <a class="el" href="a00022.html">CheckReturn</a> &amp;that)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="9da9337fca355e5dbcadc246159719f7"></a><!-- doxytag: member="Loki::CheckReturn::~CheckReturn" ref="9da9337fca355e5dbcadc246159719f7" args="(void)" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00022.html#9da9337fca355e5dbcadc246159719f7">~CheckReturn</a> (void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Destructor checks if return value was used. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="6a77fab4729207c4c74ac74317ba58d6"></a><!-- doxytag: member="Loki::CheckReturn::operator Value" ref="6a77fab4729207c4c74ac74317ba58d6" args="(void)" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00022.html#6a77fab4729207c4c74ac74317ba58d6">operator Value</a> (void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Conversion operator changes <a class="el" href="a00022.html">CheckReturn</a> back to Value type. <br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
<h3>template&lt;class Value, template&lt; class &gt; class OnError = TriggerAssert&gt;<br>
 class Loki::CheckReturn&lt; Value, OnError &gt;</h3>

<dl class="user" compact><dt><b>Purpose</b></dt><dd>C++ provides no mechanism within the language itself to force code to check the return value from a function call. This simple class provides a mechanism by which programmers can force calling functions to check the return value. Or at least make them consciously choose to disregard the return value. If the calling function fails to use or store the return value, the destructor calls the OnError policy.</dd></dl>
<dl class="user" compact><dt><b>Template Parameters</b></dt><dd><a class="el" href="a00022.html">CheckReturn</a> has two template parameters, Value and OnError.<ul>
<li>Value is the return type from the function. <a class="el" href="a00022.html">CheckReturn</a> stores a copy of it rather than a reference or pointer since return value could be local to a function. <a class="el" href="a00022.html">CheckReturn</a> works best when the return type is a built-in primitive (bool, int, etc...) a pointer, or an enum (such as an error condition enum). It can work with other types that have cheap copy operations.</li><li>OnError is a policy class indicating how to handle the situation when a caller does not check or copy the returned value. <a class="el" href="a00192.html">Loki</a> provides some policy classs and you may also write your own. For example, you can write a policy to create a message box when the function ignores the return value. That would quickly tell you places where code ignores the function call. If your write your own, you only need a templated class or struct with a public function named "run" that accepts a reference to a const value.</li></ul>
</dd></dl>
<dl class="user" compact><dt><b>Provided Policy Classes</b></dt><dd><ul>
<li>IgnoreReturnValue Deliberately ignores when the caller ignores the return value.</li><li>TriggerAssert Asserts in debug builds if the caller ignores the return value.</li><li>FprintfStderr Prints out an error message if the caller ignores the return value.</li><li>ThrowTheValue Throws the ignored value as an exception.</li><li>ThrowLogicError Throws a logic_error exception to indicate a programming error. </li></ul>
</dd></dl>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="c25f0d90452244c84dafbb23c5cdb012"></a><!-- doxytag: member="Loki::CheckReturn::CheckReturn" ref="c25f0d90452244c84dafbb23c5cdb012" args="(const CheckReturn &amp;that)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class Value , template&lt; class &gt; class OnError = TriggerAssert&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="a00022.html">Loki::CheckReturn</a>&lt; Value, OnError &gt;::<a class="el" href="a00022.html">CheckReturn</a>           </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="a00022.html">CheckReturn</a>&lt; Value, OnError &gt; &amp;&nbsp;</td>
          <td class="paramname"> <em>that</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Copy-constructor allows functions to call another function within the return statement. The other CheckReturn's m_checked flag is set since its duty has been passed to the m_checked flag in this one. 
<p>References <a class="el" href="a00233.html#l00155">Loki::CheckReturn&lt; Value, OnError &gt;::m_checked</a>.</p>

</div>
</div><p>
<hr>The documentation for this class was generated from the following file:<ul>
<li>CheckReturn.h</ul>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Thu Jan 29 18:51:42 2009 for Loki by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>