123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
- <title>Types</title>
- <link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
- <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
- <link rel="home" href="../../index.html" title="Chapter 1. The Variadic Macro Data Library 1.9">
- <link rel="up" href="../vmd_specific.html" title="Specific macros for working with data types">
- <link rel="prev" href="vmd_number.html" title="Numbers">
- <link rel="next" href="vmd_pp_data_types.html" title="VMD and Boost PP data types">
- </head>
- <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
- <table cellpadding="2" width="100%"><tr>
- <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
- <td align="center"><a href="../../../../../../index.html">Home</a></td>
- <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
- <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
- <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
- <td align="center"><a href="../../../../../../more/index.htm">More</a></td>
- </tr></table>
- <hr>
- <div class="spirit-nav">
- <a accesskey="p" href="vmd_number.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_pp_data_types.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
- </div>
- <div class="section">
- <div class="titlepage"><div><div><h3 class="title">
- <a name="variadic_macro_data.vmd_specific.vmd_type"></a><a class="link" href="vmd_type.html" title="Types">Types</a>
- </h3></div></div></div>
- <p>
- A subset of identifiers is VMD types, called a 'v-type'. These are identifiers
- which represent all of the preprocessor data types which VMD can parse. This
- subset of identifiers is automatically registered and pre-detected by VMD.
- Each identifier type begins with the unique prefix 'BOOST_VMD_TYPE_'.
- </p>
- <p>
- The actual types are:
- </p>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
- <li class="listitem">
- BOOST_VMD_TYPE_EMPTY, represents emptiness, ie. "empty data"
- </li>
- <li class="listitem">
- BOOST_VMD_TYPE_ARRAY, a Boost PP array
- </li>
- <li class="listitem">
- BOOST_VMD_TYPE_LIST, a Boost PP list
- </li>
- <li class="listitem">
- BOOST_VMD_TYPE_SEQ, a Boost PP seq
- </li>
- <li class="listitem">
- BOOST_VMD_TYPE_TUPLE, a Boost PP tuple
- </li>
- <li class="listitem">
- BOOST_VMD_TYPE_IDENTIFIER, identifier
- </li>
- <li class="listitem">
- BOOST_BMD_TYPE_NUMBER, a number
- </li>
- <li class="listitem">
- BOOST_VMD_TYPE_TYPE, a type itself
- </li>
- <li class="listitem">
- BOOST_VMD_TYPE_SEQUENCE, a sequence
- </li>
- <li class="listitem">
- BOOST_VMD_TYPE_UNKNOWN, an unknown type
- </li>
- </ul></div>
- <p>
- Since a v-type is itself an identifier the particular constraint on the input
- to test is exactly the same as for identifiers.
- </p>
- <p>
- The constraint is that the beginning input character, ignoring any whitespace,
- passed as the input to test must be either:
- </p>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
- <li class="listitem">
- an identifier character, ie. an alphanumeric or an underscore
- </li>
- <li class="listitem">
- the left parenthesis of a tuple
- </li>
- </ul></div>
- <p>
- and if the first character is not the left parenthesis of a tuple the remaining
- characters must be alphanumeric or an underscore until a space character
- or end of input occurs.
- </p>
- <p>
- If this is not the case the behavior is undefined, and most likely a preprocessing
- error will occur.
- </p>
- <p>
- The macro used to test for a particular type in VMD is called BOOST_VMD_IS_TYPE.
- The macro takes a single parameter, the input to test against.
- </p>
- <p>
- The macro returns 1 if the parameter is a v-type, otherwise the macro returns
- 0.
- </p>
- <p>
- A v-type is also an identifier, which has been registered and pre-detected,
- so you can also use the VMD functionality which works with identifiers to
- work with a v-type as an identifier if you like.
- </p>
- <h5>
- <a name="variadic_macro_data.vmd_specific.vmd_type.h0"></a>
- <span class="phrase"><a name="variadic_macro_data.vmd_specific.vmd_type.example"></a></span><a class="link" href="vmd_type.html#variadic_macro_data.vmd_specific.vmd_type.example">Example</a>
- </h5>
- <p>
- Let us look at an example of how to use BOOST_VMD_IS_TYPE.
- </p>
- <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">vmd</span><span class="special">/</span><span class="identifier">is_type</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
- <span class="identifier">BOOST_VMD_IS_TYPE</span><span class="special">(</span><span class="identifier">input</span><span class="special">)</span>
- <span class="identifier">returns</span><span class="special">:</span>
- <span class="keyword">if</span> <span class="identifier">input</span> <span class="special">=</span> <span class="identifier">BOOST_VMD_TYPE_SEQ</span><span class="special">,</span> <span class="number">1</span>
- <span class="keyword">if</span> <span class="identifier">input</span> <span class="special">=</span> <span class="identifier">BOOST_VMD_TYPE_NUMBER</span><span class="special">,</span> <span class="number">1</span>
- <span class="keyword">if</span> <span class="identifier">input</span> <span class="special">=</span> <span class="identifier">SQUARE</span><span class="special">,</span> <span class="number">0</span>
- <span class="keyword">if</span> <span class="identifier">input</span> <span class="special">=</span> <span class="identifier">BOOST_VMD_TYPE_IDENTIFIER</span> <span class="identifier">DATA</span><span class="special">,</span> <span class="number">0</span> <span class="identifier">since</span> <span class="identifier">there</span> <span class="identifier">are</span> <span class="identifier">tokens</span> <span class="identifier">after</span> <span class="identifier">the</span> <span class="identifier">type</span>
- <span class="keyword">if</span> <span class="identifier">input</span> <span class="special">=</span> <span class="special">%</span><span class="number">44</span><span class="special">,</span> <span class="identifier">does</span> <span class="keyword">not</span> <span class="identifier">meet</span> <span class="identifier">the</span> <span class="identifier">constraint</span> <span class="identifier">therefore</span> <span class="identifier">undefined</span> <span class="identifier">behavior</span>
- <span class="keyword">if</span> <span class="identifier">input</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">BOOST_VMD_TYPE_EMPTY</span> <span class="special">),</span> <span class="number">0</span> <span class="identifier">since</span> <span class="identifier">the</span> <span class="identifier">macro</span> <span class="identifier">begins</span> <span class="identifier">with</span> <span class="identifier">a</span> <span class="identifier">tuple</span> <span class="keyword">and</span> <span class="keyword">this</span> <span class="identifier">can</span> <span class="identifier">be</span> <span class="identifier">tested</span> <span class="keyword">for</span>
- </pre>
- <h5>
- <a name="variadic_macro_data.vmd_specific.vmd_type.h1"></a>
- <span class="phrase"><a name="variadic_macro_data.vmd_specific.vmd_type.usage"></a></span><a class="link" href="vmd_type.html#variadic_macro_data.vmd_specific.vmd_type.usage">Usage</a>
- </h5>
- <p>
- To use the BOOST_VMD_IS_TYPE macro either include the general header:
- </p>
- <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">vmd</span><span class="special">/</span><span class="identifier">vmd</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
- </pre>
- <p>
- or include the specific header:
- </p>
- <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">vmd</span><span class="special">/</span><span class="identifier">is_type</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
- </pre>
- </div>
- <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
- <td align="left"></td>
- <td align="right"><div class="copyright-footer">Copyright © 2010-2017 Tropic Software
- East Inc</div></td>
- </tr></table>
- <hr>
- <div class="spirit-nav">
- <a accesskey="p" href="vmd_number.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_pp_data_types.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
- </div>
- </body>
- </html>
|