| 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_HAS_XXX_TRAIT_NAMED_DEF</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="./has-xxx-trait-def.html" class="navigation-link">Prev</a> <a href="./configuration.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./has-xxx-trait-def.html" class="navigation-link">Back</a> Along</span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./introspection.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="./introspection.html" class="navigation-link">Introspection</a> / <a href="./has-xxx-trait-named-def.html" class="navigation-link">BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF</a></td> |
|---|
| 16 | </tr></table><div class="header-separator"></div> |
|---|
| 17 | <div class="section" id="has-xxx-trait-named-def"> |
|---|
| 18 | <h1><a class="toc-backref" href="./introspection.html#id517" name="has-xxx-trait-named-def">BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF</a></h1> |
|---|
| 19 | <div class="section" id="macros-introspection-has-synopsis"> |
|---|
| 20 | <h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3> |
|---|
| 21 | <pre class="literal-block"> |
|---|
| 22 | #define <a href="./has-xxx-trait-named-def.html" class="identifier">BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF</a>(trait, name, default_) \ |
|---|
| 23 | <em>unspecified token sequence</em> \ |
|---|
| 24 | /**/ |
|---|
| 25 | </pre> |
|---|
| 26 | </div> |
|---|
| 27 | <div class="section" id="macros-introspection-has-description"> |
|---|
| 28 | <h3><a class="subsection-title" href="#description" name="description">Description</a></h3> |
|---|
| 29 | <p>Expands into a definition of a boolean unary <a class="reference" href="./metafunction.html">Metafunction</a> <tt class="literal"><span class="pre">trait</span></tt> |
|---|
| 30 | such that for any type <tt class="literal"><span class="pre">x</span></tt> <tt class="literal"><span class="pre">trait<x>::value</span> <span class="pre">==</span> <span class="pre">true</span></tt> if and only |
|---|
| 31 | if <tt class="literal"><span class="pre">x</span></tt> is a class type and has a nested type memeber <tt class="literal"><span class="pre">x::name</span></tt>.</p> |
|---|
| 32 | <p>On the deficient compilers not capabale of performing the detection, |
|---|
| 33 | <tt class="literal"><span class="pre">trait<x>::value</span></tt> always returns a fallback value <tt class="literal"><span class="pre">default_</span></tt>. |
|---|
| 34 | A boolean configuraion macro, <a class="refentry reference" href="./cfg-no-has-xxx.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_CFG_NO_HAS_XXX</span></tt></a>, is provided |
|---|
| 35 | to signal or override the "deficient" status of a particular compiler. |
|---|
| 36 | [<em>Note:</em> The fallback value call also be provided at the point of the |
|---|
| 37 | metafunction invocation; see the <cite>Expression semantics</cite> section for |
|---|
| 38 | details — <em>end note</em>]</p> |
|---|
| 39 | </div> |
|---|
| 40 | <div class="section" id="macros-introspection-has-header"> |
|---|
| 41 | <h3><a class="subsection-title" href="#header" name="header">Header</a></h3> |
|---|
| 42 | <pre class="literal-block"> |
|---|
| 43 | #include <<a href="../../../../boost/mpl/has_xxx.hpp" class="header">boost/mpl/has_xxx.hpp</a>> |
|---|
| 44 | </pre> |
|---|
| 45 | </div> |
|---|
| 46 | <div class="section" id="macros-introspection-has-parameters"> |
|---|
| 47 | <h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3> |
|---|
| 48 | <table border="1" class="table"> |
|---|
| 49 | <colgroup> |
|---|
| 50 | <col width="15%" /> |
|---|
| 51 | <col width="32%" /> |
|---|
| 52 | <col width="53%" /> |
|---|
| 53 | </colgroup> |
|---|
| 54 | <thead valign="bottom"> |
|---|
| 55 | <tr><th>Parameter</th> |
|---|
| 56 | <th>Requirement</th> |
|---|
| 57 | <th>Description</th> |
|---|
| 58 | </tr> |
|---|
| 59 | </thead> |
|---|
| 60 | <tbody valign="top"> |
|---|
| 61 | <tr><td><tt class="literal"><span class="pre">trait</span></tt></td> |
|---|
| 62 | <td>A legal identifier token</td> |
|---|
| 63 | <td>A name of the metafunction to be generated.</td> |
|---|
| 64 | </tr> |
|---|
| 65 | <tr><td><tt class="literal"><span class="pre">name</span></tt></td> |
|---|
| 66 | <td>A legal identifier token</td> |
|---|
| 67 | <td>A name of the member being detected.</td> |
|---|
| 68 | </tr> |
|---|
| 69 | <tr><td><tt class="literal"><span class="pre">default_</span></tt></td> |
|---|
| 70 | <td>An boolean constant</td> |
|---|
| 71 | <td>A fallback value for the deficient compilers.</td> |
|---|
| 72 | </tr> |
|---|
| 73 | </tbody> |
|---|
| 74 | </table> |
|---|
| 75 | </div> |
|---|
| 76 | <div class="section" id="macros-introspection-has-expression-semantics"> |
|---|
| 77 | <h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3> |
|---|
| 78 | <p>For any legal C++ identifiers <tt class="literal"><span class="pre">trait</span></tt> and <tt class="literal"><span class="pre">name</span></tt>, boolean constant expression <tt class="literal"><span class="pre">c1</span></tt>, |
|---|
| 79 | boolean <a class="reference" href="./integral-constant.html">Integral Constant</a> <tt class="literal"><span class="pre">c2</span></tt>, and arbitrary type <tt class="literal"><span class="pre">x</span></tt>:</p> |
|---|
| 80 | <pre class="literal-block"> |
|---|
| 81 | <a href="./has-xxx-trait-named-def.html" class="identifier">BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF</a>(trait, name, c1) |
|---|
| 82 | </pre> |
|---|
| 83 | <table class="field-list" frame="void" rules="none"> |
|---|
| 84 | <col class="field-name" /> |
|---|
| 85 | <col class="field-body" /> |
|---|
| 86 | <tbody valign="top"> |
|---|
| 87 | <tr class="field"><th class="field-name">Precondition:</th><td class="field-body">Appears at namespace scope.</td> |
|---|
| 88 | </tr> |
|---|
| 89 | <tr class="field"><th class="field-name">Return type:</th><td class="field-body">None.</td> |
|---|
| 90 | </tr> |
|---|
| 91 | <tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Expands into an equivalent of the following class template definition</p> |
|---|
| 92 | <pre class="literal-block"> |
|---|
| 93 | template< typename X, typename fallback = boost::mpl::<a href="./bool.html" class="identifier">bool_</a><c1> > |
|---|
| 94 | struct trait |
|---|
| 95 | { |
|---|
| 96 | // <em>unspecified</em> |
|---|
| 97 | // ... |
|---|
| 98 | }; |
|---|
| 99 | </pre> |
|---|
| 100 | <p>where <tt class="literal"><span class="pre">trait</span></tt> is a boolean <a class="reference" href="./metafunction.html">Metafunction</a> with the following semantics:</p> |
|---|
| 101 | <pre class="literal-block"> |
|---|
| 102 | typedef trait<x>::type r; |
|---|
| 103 | </pre> |
|---|
| 104 | <table class="field-list" frame="void" rules="none"> |
|---|
| 105 | <col class="field-name" /> |
|---|
| 106 | <col class="field-body" /> |
|---|
| 107 | <tbody valign="top"> |
|---|
| 108 | <tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td> |
|---|
| 109 | </tr> |
|---|
| 110 | <tr class="field"><th class="field-name">Semantics:</th><td class="field-body">If <a class="refentry reference" href="./cfg-no-has-xxx.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_CFG_NO_HAS_XXX</span></tt></a> is defined, <tt class="literal"><span class="pre">r::value</span> <span class="pre">==</span> <span class="pre">c1</span></tt>; |
|---|
| 111 | otherwise, <tt class="literal"><span class="pre">r::value</span> <span class="pre">==</span> <span class="pre">true</span></tt> if and only if <tt class="literal"><span class="pre">x</span></tt> is a class type |
|---|
| 112 | that has a nested type memeber <tt class="literal"><span class="pre">x::name</span></tt>.</td> |
|---|
| 113 | </tr> |
|---|
| 114 | </tbody> |
|---|
| 115 | </table> |
|---|
| 116 | <pre class="literal-block"> |
|---|
| 117 | typedef trait< x,c2 >::type r; |
|---|
| 118 | </pre> |
|---|
| 119 | <table class="last field-list" frame="void" rules="none"> |
|---|
| 120 | <col class="field-name" /> |
|---|
| 121 | <col class="field-body" /> |
|---|
| 122 | <tbody valign="top"> |
|---|
| 123 | <tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td> |
|---|
| 124 | </tr> |
|---|
| 125 | <tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">If <a class="refentry reference" href="./cfg-no-has-xxx.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_CFG_NO_HAS_XXX</span></tt></a> is defined, <tt class="literal"><span class="pre">r::value</span> <span class="pre">==</span> <span class="pre">c2::value</span></tt>; |
|---|
| 126 | otherwise, equivalent to</p> |
|---|
| 127 | <pre class="last literal-block"> |
|---|
| 128 | typedef trait<x>::type r; |
|---|
| 129 | </pre> |
|---|
| 130 | </td> |
|---|
| 131 | </tr> |
|---|
| 132 | </tbody> |
|---|
| 133 | </table> |
|---|
| 134 | </td> |
|---|
| 135 | </tr> |
|---|
| 136 | </tbody> |
|---|
| 137 | </table> |
|---|
| 138 | </div> |
|---|
| 139 | <div class="section" id="macros-introspection-has-example"> |
|---|
| 140 | <h3><a class="subsection-title" href="#example" name="example">Example</a></h3> |
|---|
| 141 | <pre class="literal-block"> |
|---|
| 142 | <a href="./has-xxx-trait-named-def.html" class="identifier">BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF</a>(has_xxx, xxx, false) |
|---|
| 143 | |
|---|
| 144 | struct test1 {}; |
|---|
| 145 | struct test2 { void xxx(); }; |
|---|
| 146 | struct test3 { int xxx; }; |
|---|
| 147 | struct test4 { static int xxx(); }; |
|---|
| 148 | struct test5 { template< typename T > struct xxx {}; }; |
|---|
| 149 | struct test6 { typedef int xxx; }; |
|---|
| 150 | struct test7 { struct xxx; }; |
|---|
| 151 | struct test8 { typedef void (*xxx)(); }; |
|---|
| 152 | struct test9 { typedef void (xxx)(); }; |
|---|
| 153 | |
|---|
| 154 | <a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( has_xxx<test1> )); |
|---|
| 155 | <a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( has_xxx<test2> )); |
|---|
| 156 | <a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( has_xxx<test3> )); |
|---|
| 157 | <a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( has_xxx<test4> )); |
|---|
| 158 | <a href="./assert-not.html" class="identifier">BOOST_MPL_ASSERT_NOT</a>(( has_xxx<test5> )); |
|---|
| 159 | |
|---|
| 160 | #if !defined(<a href="./cfg-no-has-xxx.html" class="identifier">BOOST_MPL_CFG_NO_HAS_XXX</a>) |
|---|
| 161 | <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( has_xxx<test6> )); |
|---|
| 162 | <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( has_xxx<test7> )); |
|---|
| 163 | <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( has_xxx<test8> )); |
|---|
| 164 | <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( has_xxx<test9> )); |
|---|
| 165 | #endif |
|---|
| 166 | |
|---|
| 167 | <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( has_xxx<test6,true_> )); |
|---|
| 168 | <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( has_xxx<test7,true_> )); |
|---|
| 169 | <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( has_xxx<test8,true_> )); |
|---|
| 170 | <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( has_xxx<test9,true_> )); |
|---|
| 171 | </pre> |
|---|
| 172 | </div> |
|---|
| 173 | <div class="section" id="macros-introspection-has-see-also"> |
|---|
| 174 | <h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3> |
|---|
| 175 | <p><a class="reference" href="./macros.html">Macros</a>, <a class="refentry reference" href="./has-xxx-trait-def.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_HAS_XXX_TRAIT_DEF</span></tt></a>, <a class="refentry reference" href="./cfg-no-has-xxx.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_CFG_NO_HAS_XXX</span></tt></a></p> |
|---|
| 176 | <!-- modtime: November 13, 2004 02:53:15 +0000 --> |
|---|
| 177 | </div> |
|---|
| 178 | </div> |
|---|
| 179 | |
|---|
| 180 | <div class="footer-separator"></div> |
|---|
| 181 | <table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./has-xxx-trait-def.html" class="navigation-link">Prev</a> <a href="./configuration.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./has-xxx-trait-def.html" class="navigation-link">Back</a> Along</span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./introspection.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> |
|---|
| 182 | </tr></table></body> |
|---|
| 183 | </html> |
|---|