Imported Upstream version 1.64.0
[platform/upstream/boost.git] / libs / vmd / doc / html / variadic_macro_data / vmd_specific / vmd_identifying.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Identifying data types</title>
5 <link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;The Variadic Macro Data Library 1.9">
8 <link rel="up" href="../vmd_specific.html" title="Specific macros for working with data types">
9 <link rel="prev" href="vmd_pp_data_types.html" title="VMD and Boost PP data types">
10 <link rel="next" href="../vmd_generic.html" title="Generic macros for working with data types">
11 </head>
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../more/index.htm">More</a></td>
20 </tr></table>
21 <hr>
22 <div class="spirit-nav">
23 <a accesskey="p" href="vmd_pp_data_types.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../vmd_specific.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../vmd_generic.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24 </div>
25 <div class="section">
26 <div class="titlepage"><div><div><h3 class="title">
27 <a name="variadic_macro_data.vmd_specific.vmd_identifying"></a><a class="link" href="vmd_identifying.html" title="Identifying data types">Identifying
28       data types</a>
29 </h3></div></div></div>
30 <h5>
31 <a name="variadic_macro_data.vmd_specific.vmd_identifying.h0"></a>
32         <span class="phrase"><a name="variadic_macro_data.vmd_specific.vmd_identifying.identifying_macros_and_boost_vmd"></a></span><a class="link" href="vmd_identifying.html#variadic_macro_data.vmd_specific.vmd_identifying.identifying_macros_and_boost_vmd">Identifying
33         macros and BOOST_VMD_IS_EMPTY </a>
34       </h5>
35 <p>
36         The various macros for identifying VMD data types complement the ability
37         to identify emptiness using BOOST_VMD_IS_EMPTY. The general name I will use
38         in this documentation for these specific macros is "identifying macros."
39         The identifying macros also share with BOOST_VMD_IS_EMPTY the inherent flaw
40         mentioned when discussing BOOST_VMD_IS_EMPTY, since they themselves use BOOST_VMD_IS_EMPTY
41         to determine that the input has ended.
42       </p>
43 <p>
44         To recapitulate the flaw with BOOST_VMD_IS_EMPTY:
45       </p>
46 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
47 <li class="listitem">
48             using a standard C++ compiler if the input ends with the name of a function-like
49             macro, and that macro takes two or more parameters, a preprocessing error
50             will occur.
51           </li>
52 <li class="listitem">
53             using the VC++ compiler if the input consists of the name of a function-like
54             macro, and that macro when invoked with no parameters returns a tuple,
55             the macro erroneously returns 1, meaning that the input is empty.
56           </li>
57 <li class="listitem">
58             even if the function-like macro takes one parameter, passing emptiness
59             to that macro could cause a preprocessing error.
60           </li>
61 </ul></div>
62 <p>
63         The obvious way to avoid the BOOST_VMD_IS_EMPTY problem with the identifying
64         macros is to design input so that the name of a function-like macro is never
65         passed as a parameter. This can be done, if one uses VMD and has situations
66         where the input could contain a function-like macro name, by having that
67         function-like macro name placed within a Boost PP data type, such as a tuple,
68         without attempting to identify the type of the tuple element using VMD. In
69         other word if the input is:
70       </p>
71 <pre class="programlisting"><span class="special">(</span> <span class="identifier">SOME_FUNCTION_MACRO_NAME</span> <span class="special">)</span>
72 </pre>
73 <p>
74         and we have the macro definition:
75       </p>
76 <pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">SOME_FUNCTION_MACRO_NAME</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span><span class="identifier">y</span><span class="special">)</span> <span class="identifier">some_output</span>
77 </pre>
78 <p>
79         VMD can still parse the input as a tuple, if desired, using BOOST_VMD_IS_TUPLE
80         without encountering the BOOST_VMD_IS_EMPTY problem. However if the input
81         is:
82       </p>
83 <pre class="programlisting"><span class="identifier">SOME_FUNCTION_MACRO_NAME</span>
84 </pre>
85 <p>
86         either directly or through accessing the above tuple's first element, and
87         the programmer attempts to use BOOST_VMD_IS_IDENTIFIER with this input, the
88         BOOST_VMD_IS_EMPTY problem will occur.
89       </p>
90 <h5>
91 <a name="variadic_macro_data.vmd_specific.vmd_identifying.h1"></a>
92         <span class="phrase"><a name="variadic_macro_data.vmd_specific.vmd_identifying.identifying_macros_and_programmi"></a></span><a class="link" href="vmd_identifying.html#variadic_macro_data.vmd_specific.vmd_identifying.identifying_macros_and_programmi">Identifying
93         macros and programming flexibility </a>
94       </h5>
95 <p>
96         The VMD identifying macros give the preprocessor metaprogrammer a great amount
97         of flexibility when designing macros. It is not merely the flexibility of
98         allowing direct parameters to a macro to be different data types, and having
99         the macro work differently depending on the type of data passed to it, but
100         it is also the flexibility of allowing individual elements of the higher
101         level Boost PP data types to be different data types and have the macro work
102         correctly depending on the type of data type passed as part of those elements.
103       </p>
104 <p>
105         With this flexibility also comes a greater amount of responsibility. For
106         the macro designer this responsibility is twofold:
107       </p>
108 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
109 <li class="listitem">
110             To carefully document the possible combinations of acceptable data and
111             what they mean.
112           </li>
113 <li class="listitem">
114             To balance flexibility with ease of use so that the macro does not become
115             so hard to understand that the programmer invoking the macro gives up
116             using it entirely.
117           </li>
118 </ul></div>
119 <p>
120         For the programmer invoking a macro the responsibility is to understand the
121         documentation and not attempt to pass to the macro data which may cause incorrect
122         results or preprocessing errors.
123       </p>
124 </div>
125 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
126 <td align="left"></td>
127 <td align="right"><div class="copyright-footer">Copyright &#169; 2010-2017 Tropic Software
128       East Inc</div></td>
129 </tr></table>
130 <hr>
131 <div class="spirit-nav">
132 <a accesskey="p" href="vmd_pp_data_types.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../vmd_specific.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../vmd_generic.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
133 </div>
134 </body>
135 </html>