| 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 | <!-- Copyright Aleksey Gurtovoy 2006. Distributed under the Boost --> |
|---|
| 5 | <!-- Software License, Version 1.0. (See accompanying --> |
|---|
| 6 | <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) --> |
|---|
| 7 | <head> |
|---|
| 8 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|---|
| 9 | <meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" /> |
|---|
| 10 | <title>The MPL Reference Manual: BOOST_MPL_ASSERT_RELATION</title> |
|---|
| 11 | <link rel="stylesheet" href="../style.css" type="text/css" /> |
|---|
| 12 | </head> |
|---|
| 13 | <body class="docframe refmanual"> |
|---|
| 14 | <table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./assert-not.html" class="navigation-link">Prev</a> <a href="./introspection.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./assert-not.html" class="navigation-link">Back</a> Along</span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./asserts.html" class="navigation-link">Up</a> <a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td> |
|---|
| 15 | <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-relation.html" class="navigation-link">BOOST_MPL_ASSERT_RELATION</a></td> |
|---|
| 16 | </tr></table><div class="header-separator"></div> |
|---|
| 17 | <div class="section" id="assert-relation"> |
|---|
| 18 | <h1><a class="toc-backref" href="./asserts.html#id514" name="assert-relation">BOOST_MPL_ASSERT_RELATION</a></h1> |
|---|
| 19 | <div class="section" id="the-macros-asserts-assert-synopsis"> |
|---|
| 20 | <h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3> |
|---|
| 21 | <pre class="literal-block"> |
|---|
| 22 | #define <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( x, relation, y ) \ |
|---|
| 23 | <em>unspecified token sequence</em> \ |
|---|
| 24 | /**/ |
|---|
| 25 | </pre> |
|---|
| 26 | </div> |
|---|
| 27 | <div class="section" id="the-macros-asserts-assert-description"> |
|---|
| 28 | <h3><a class="subsection-title" href="#description" name="description">Description</a></h3> |
|---|
| 29 | <p>A specialized assertion macro for checking numerical conditions. Generates |
|---|
| 30 | a compilation error when the condition <tt class="literal"><span class="pre">(</span> <span class="pre">x</span> <span class="pre">relation</span> <span class="pre">y</span> <span class="pre">)</span></tt> |
|---|
| 31 | doesn't hold.</p> |
|---|
| 32 | </div> |
|---|
| 33 | <div class="section" id="the-macros-asserts-assert-header"> |
|---|
| 34 | <h3><a class="subsection-title" href="#header" name="header">Header</a></h3> |
|---|
| 35 | <pre class="literal-block"> |
|---|
| 36 | #include <<a href="../../../../boost/mpl/assert.hpp" class="header">boost/mpl/assert.hpp</a>> |
|---|
| 37 | </pre> |
|---|
| 38 | </div> |
|---|
| 39 | <div class="section" id="the-macros-asserts-assert-parameters"> |
|---|
| 40 | <h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3> |
|---|
| 41 | <table border="1" class="table"> |
|---|
| 42 | <colgroup> |
|---|
| 43 | <col width="15%" /> |
|---|
| 44 | <col width="36%" /> |
|---|
| 45 | <col width="48%" /> |
|---|
| 46 | </colgroup> |
|---|
| 47 | <thead valign="bottom"> |
|---|
| 48 | <tr><th>Parameter</th> |
|---|
| 49 | <th>Requirement</th> |
|---|
| 50 | <th>Description</th> |
|---|
| 51 | </tr> |
|---|
| 52 | </thead> |
|---|
| 53 | <tbody valign="top"> |
|---|
| 54 | <tr><td><tt class="literal"><span class="pre">x</span></tt></td> |
|---|
| 55 | <td>An integral constant</td> |
|---|
| 56 | <td>Left operand of the checked relation.</td> |
|---|
| 57 | </tr> |
|---|
| 58 | <tr><td><tt class="literal"><span class="pre">y</span></tt></td> |
|---|
| 59 | <td>An integral constant</td> |
|---|
| 60 | <td>Right operand of the checked relation.</td> |
|---|
| 61 | </tr> |
|---|
| 62 | <tr><td><tt class="literal"><span class="pre">relation</span></tt></td> |
|---|
| 63 | <td>A C++ operator token</td> |
|---|
| 64 | <td>An operator token for the relation being |
|---|
| 65 | checked.</td> |
|---|
| 66 | </tr> |
|---|
| 67 | </tbody> |
|---|
| 68 | </table> |
|---|
| 69 | </div> |
|---|
| 70 | <div class="section" id="the-macros-asserts-assert-expression-semantics"> |
|---|
| 71 | <h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3> |
|---|
| 72 | <p>For any integral constants <tt class="literal"><span class="pre">x</span></tt>, <tt class="literal"><span class="pre">y</span></tt> and a legal C++ operator token <tt class="literal"><span class="pre">op</span></tt>:</p> |
|---|
| 73 | <pre class="literal-block"> |
|---|
| 74 | <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( x, op, y ); |
|---|
| 75 | </pre> |
|---|
| 76 | <table class="field-list" frame="void" rules="none"> |
|---|
| 77 | <col class="field-name" /> |
|---|
| 78 | <col class="field-body" /> |
|---|
| 79 | <tbody valign="top"> |
|---|
| 80 | <tr class="field"><th class="field-name">Return type:</th><td class="field-body">None.</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">(</span> <span class="pre">x</span> <span class="pre">op</span> <span class="pre">y</span> <span class="pre">)</span> <span class="pre">!=</span> <span class="pre">true</span></tt>, otherwise |
|---|
| 83 | has no effect.</p> |
|---|
| 84 | <p>When possible within the compiler's diagnostic capabilities, |
|---|
| 85 | the error message will include a name of the relation being checked, |
|---|
| 86 | the actual values of both operands, and have a general form of:</p> |
|---|
| 87 | <pre class="last literal-block"> |
|---|
| 88 | <em>...</em> ************<em>...</em>assert_relation<op, x, y>::************) <em>...</em> |
|---|
| 89 | </pre> |
|---|
| 90 | </td> |
|---|
| 91 | </tr> |
|---|
| 92 | </tbody> |
|---|
| 93 | </table> |
|---|
| 94 | </div> |
|---|
| 95 | <div class="section" id="the-macros-asserts-assert-example"> |
|---|
| 96 | <h3><a class="subsection-title" href="#example" name="example">Example</a></h3> |
|---|
| 97 | <pre class="literal-block"> |
|---|
| 98 | template< typename T, typename U > struct my |
|---|
| 99 | { |
|---|
| 100 | // ... |
|---|
| 101 | <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( sizeof(T), <, sizeof(U) ); |
|---|
| 102 | }; |
|---|
| 103 | |
|---|
| 104 | my<char[50],char[10]> test; |
|---|
| 105 | |
|---|
| 106 | // In instantiation of `my<char[50], char[10]>': |
|---|
| 107 | // instantiated from here |
|---|
| 108 | // conversion from ` |
|---|
| 109 | // mpl_::failed************mpl_::assert_relation<<a href="./less.html" class="identifier">less</a>, 50, 10>::************' |
|---|
| 110 | // to non-scalar type `mpl_::assert<false>' requested |
|---|
| 111 | </pre> |
|---|
| 112 | </div> |
|---|
| 113 | <div class="section" id="the-macros-asserts-assert-see-also"> |
|---|
| 114 | <h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3> |
|---|
| 115 | <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-msg.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_ASSERT_MSG</span></tt></a></p> |
|---|
| 116 | <!-- modtime: November 10, 2004 04:45:16 +0000 --> |
|---|
| 117 | </div> |
|---|
| 118 | </div> |
|---|
| 119 | |
|---|
| 120 | <div class="footer-separator"></div> |
|---|
| 121 | <table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./assert-not.html" class="navigation-link">Prev</a> <a href="./introspection.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./assert-not.html" class="navigation-link">Back</a> Along</span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./asserts.html" class="navigation-link">Up</a> <a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td> |
|---|
| 122 | </tr></table></body> |
|---|
| 123 | </html> |
|---|