Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/mpl/doc/refmanual/assert-msg.html @ 12

Last change on this file since 12 was 12, checked in by landauf, 18 years ago

added boost

File size: 9.3 KB
Line 
1<?xml version="1.0" encoding="utf-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
7<title>The MPL Reference Manual: BOOST_MPL_ASSERT_MSG</title>
8<link rel="stylesheet" href="../style.css" type="text/css" />
9</head>
10<body class="docframe refmanual">
11<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./assert.html" class="navigation-link">Prev</a>&nbsp;<a href="./assert-not.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./assert.html" class="navigation-link">Back</a>&nbsp;<a href="./assert-not.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./asserts.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
12<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./macros.html" class="navigation-link">Macros</a> / <a href="./asserts.html" class="navigation-link">Asserts</a> / <a href="./assert-msg.html" class="navigation-link">BOOST_MPL_ASSERT_MSG</a></td>
13</tr></table><div class="header-separator"></div>
14<div class="section" id="assert-msg">
15<h1><a class="toc-backref" href="./asserts.html#id512" name="assert-msg">BOOST_MPL_ASSERT_MSG</a></h1>
16<div class="section" id="asserts-assert-synopsis">
17<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
18<pre class="literal-block">
19#define <a href="./assert-msg.html" class="identifier">BOOST_MPL_ASSERT_MSG</a>( condition, message, types ) \
20    <em>unspecified token sequence</em> \
21/**/
22</pre>
23</div>
24<div class="section" id="asserts-assert-description">
25<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
26<p>Generates a compilation error with an embedded custom message when the condition
27doesn't hold.</p>
28</div>
29<div class="section" id="asserts-assert-header">
30<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
31<pre class="literal-block">
32#include &lt;<a href="../../../../boost/mpl/assert.hpp" class="header">boost/mpl/assert.hpp</a>&gt;
33</pre>
34</div>
35<div class="section" id="asserts-assert-parameters">
36<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
37<table border="1" class="table">
38<colgroup>
39<col width="15%" />
40<col width="36%" />
41<col width="48%" />
42</colgroup>
43<thead valign="bottom">
44<tr><th>Parameter</th>
45<th>Requirement</th>
46<th>Description</th>
47</tr>
48</thead>
49<tbody valign="top">
50<tr><td><tt class="literal"><span class="pre">condition</span></tt></td>
51<td>An integral constant expression</td>
52<td>A condition to be asserted.</td>
53</tr>
54<tr><td><tt class="literal"><span class="pre">message</span></tt></td>
55<td>A legal identifier token</td>
56<td>A custom message in a form of a legal C++
57identifier token.</td>
58</tr>
59<tr><td><tt class="literal"><span class="pre">types</span></tt></td>
60<td>A legal function parameter list</td>
61<td>A parenthized list of types to be displayed
62in the error message.</td>
63</tr>
64</tbody>
65</table>
66</div>
67<div class="section" id="asserts-assert-expression-semantics">
68<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
69<p>For any integral constant expression <tt class="literal"><span class="pre">expr</span></tt>, legal C++ identifier <tt class="literal"><span class="pre">message</span></tt>, and
70arbitrary types <tt class="literal"><span class="pre">t1</span></tt>, <tt class="literal"><span class="pre">t2</span></tt>,... <tt class="literal"><span class="pre">tn</span></tt>:</p>
71<pre class="literal-block">
72<a href="./assert-msg.html" class="identifier">BOOST_MPL_ASSERT_MSG</a>( expr, message, (t1, t2,... tn) );
73</pre>
74<table class="field-list" frame="void" rules="none">
75<col class="field-name" />
76<col class="field-body" />
77<tbody valign="top">
78<tr class="field"><th class="field-name">Return type:</th><td class="field-body">None.</td>
79</tr>
80<tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><tt class="literal"><span class="pre">t1</span></tt>, <tt class="literal"><span class="pre">t2</span></tt>,... <tt class="literal"><span class="pre">tn</span></tt> are non-<tt class="literal"><span class="pre">void</span></tt>.</td>
81</tr>
82<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Generates a compilation error if <tt class="literal"><span class="pre">expr::value</span> <span class="pre">!=</span> <span class="pre">true</span></tt>, otherwise
83has no effect.</p>
84<p>When possible within the compiler's diagnostic capabilities,
85the error message will include the <tt class="literal"><span class="pre">message</span></tt> identifier and the parenthized
86list of <tt class="literal"><span class="pre">t1</span></tt>, <tt class="literal"><span class="pre">t2</span></tt>,... <tt class="literal"><span class="pre">tn</span></tt> types, and have a general form of:</p>
87<pre class="last literal-block">
88<em>...</em> ************( <em>...</em>::message )************)(t1, t2,... tn) <em>...</em>
89</pre>
90</td>
91</tr>
92</tbody>
93</table>
94<pre class="literal-block">
95<a href="./assert-msg.html" class="identifier">BOOST_MPL_ASSERT_MSG</a>( expr, message, (types&lt;t1, t2,... tn&gt;) );
96</pre>
97<table class="field-list" frame="void" rules="none">
98<col class="field-name" />
99<col class="field-body" />
100<tbody valign="top">
101<tr class="field"><th class="field-name">Return type:</th><td class="field-body">None.</td>
102</tr>
103<tr class="field"><th class="field-name">Precondition:</th><td class="field-body">None.</td>
104</tr>
105<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Generates a compilation error if <tt class="literal"><span class="pre">expr::value</span> <span class="pre">!=</span> <span class="pre">true</span></tt>, otherwise
106has no effect.</p>
107<p>When possible within the compiler's diagnostics capabilities,
108the error message will include the <tt class="literal"><span class="pre">message</span></tt> identifier and the list of
109<tt class="literal"><span class="pre">t1</span></tt>, <tt class="literal"><span class="pre">t2</span></tt>,... <tt class="literal"><span class="pre">tn</span></tt> types, and have a general form of:</p>
110<pre class="last literal-block">
111<em>...</em> ************( <em>...</em>::message )************)(types&lt;t1, t2,... tn&gt;) <em>...</em>
112</pre>
113</td>
114</tr>
115</tbody>
116</table>
117</div>
118<div class="section" id="asserts-assert-example">
119<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
120<pre class="literal-block">
121template&lt; typename T &gt; struct my
122{
123    // ...
124    <a href="./assert-msg.html" class="identifier">BOOST_MPL_ASSERT_MSG</a>(
125          is_integral&lt;T&gt;::value
126        , NON_INTEGRAL_TYPES_ARE_NOT_ALLOWED
127        , (T)
128        );
129};
130
131my&lt;void*&gt; test;
132
133// In instantiation of `my&lt;void*&gt;':
134//   instantiated from here
135// conversion from `
136//   mpl_::failed************(my&lt;void*&gt;::
137//   NON_INTEGRAL_TYPES_ARE_NOT_ALLOWED::************)(void*)
138//   ' to non-scalar type `mpl_::assert&lt;false&gt;' requested
139</pre>
140</div>
141<div class="section" id="asserts-assert-see-also">
142<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
143<p><a class="reference" href="./asserts.html">Asserts</a>, <a class="refentry reference" href="./assert.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT</span></tt></a>, <a class="refentry reference" href="./assert-not.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT_NOT</span></tt></a>, <a class="refentry reference" href="./assert-relation.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT_RELATION</span></tt></a></p>
144<!-- modtime: November 10, 2004 04:45:24 +0000 -->
145<!-- Macros/Asserts//BOOST_MPL_ASSERT_NOT -->
146</div>
147</div>
148
149<div class="footer-separator"></div>
150<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./assert.html" class="navigation-link">Prev</a>&nbsp;<a href="./assert-not.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./assert.html" class="navigation-link">Back</a>&nbsp;<a href="./assert-not.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./asserts.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
151</tr></table></body>
152</html>
Note: See TracBrowser for help on using the repository browser.