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