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 1. 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">
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>
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>
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
29 </h3></div></div></div>
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>
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.
44 To recapitulate the flaw with BOOST_VMD_IS_EMPTY:
46 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
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
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.
58 even if the function-like macro takes one parameter, passing emptiness
59 to that macro could cause a preprocessing error.
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:
71 <pre class="programlisting"><span class="special">(</span> <span class="identifier">SOME_FUNCTION_MACRO_NAME</span> <span class="special">)</span>
74 and we have the macro definition:
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>
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
83 <pre class="programlisting"><span class="identifier">SOME_FUNCTION_MACRO_NAME</span>
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.
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>
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.
105 With this flexibility also comes a greater amount of responsibility. For
106 the macro designer this responsibility is twofold:
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
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
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.
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 © 2010-2017 Tropic Software
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>