1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Getting the type of data</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_generic.html" title="Generic macros for working with data types"> 9<link rel="prev" href="../vmd_generic.html" title="Generic macros for working with data types"> 10<link rel="next" href="vmd_assert.html" title="Testing for equality and inequality"> 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_generic.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../vmd_generic.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_assert.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_generic.vmd_convert_sequence"></a><a class="link" href="vmd_convert_sequence.html" title="Getting the type of data">Getting 28 the type of data</a> 29</h3></div></div></div> 30<p> 31 VMD has the ability to retrieve the type of any data which it can parse, 32 which means any VMD sequence. The macro to do this is called BOOST_VMD_GET_TYPE 33 and it takes a single required variadic parameter, which is a VMD sequence. 34 Since a VMD sequence is any data which VMD can parse the BOOST_VMD_GET_TYPE 35 macro works with any VMD data. 36 </p> 37<p> 38 It returns one of the types previously discussed when introducing v-types 39 as an identifier subset. As explained previously in that topic a v-type is 40 fully recognized by VMD macros and can be part of a sequence and passed as 41 VMD data just like all the other data types VMD recognizes. 42 </p> 43<p> 44 When BOOST_VMD_GET_TYPE returns the type of data it returns by default the 45 most specific type that the data can be. This means that non-empty lists 46 and arrays are returned as such, not as tuples, and numbers and types and 47 empty lists are returned as such, not as identifiers. 48 </p> 49<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">get_type</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 50 51<span class="preprocessor">#define</span> <span class="identifier">BOOST_VMD_REGISTER_ANID</span> <span class="special">(</span><span class="identifier">ANID</span><span class="special">)</span> 52<span class="preprocessor">#define</span> <span class="identifier">SEQUENCE_EMPTY</span> 53<span class="preprocessor">#define</span> <span class="identifier">SEQUENCE_MULTI</span> <span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="number">2</span><span class="special">,</span><span class="number">3</span><span class="special">)</span> <span class="number">88</span> 54<span class="preprocessor">#define</span> <span class="identifier">SEQUENCE1</span> <span class="special">(</span><span class="number">3</span><span class="special">,(</span><span class="number">1</span><span class="special">,</span><span class="number">2</span><span class="special">,</span><span class="number">3</span><span class="special">))</span> 55<span class="preprocessor">#define</span> <span class="identifier">SEQUENCE2</span> <span class="identifier">ANID</span> 56<span class="preprocessor">#define</span> <span class="identifier">SEQUENCE3</span> <span class="special">(</span><span class="number">1</span><span class="special">,(</span><span class="number">2</span><span class="special">,(</span><span class="number">3</span><span class="special">,</span><span class="identifier">BOOST_PP_NIL</span><span class="special">)))</span> 57<span class="preprocessor">#define</span> <span class="identifier">SEQUENCE4</span> <span class="number">1</span> 58<span class="preprocessor">#define</span> <span class="identifier">SEQUENCE5</span> <span class="special">(</span><span class="number">1</span><span class="special">)(</span><span class="number">2</span><span class="special">)(</span><span class="number">3</span><span class="special">)</span> 59<span class="preprocessor">#define</span> <span class="identifier">SEQUENCE6</span> <span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="number">2</span><span class="special">,</span><span class="number">3</span><span class="special">)</span> 60<span class="preprocessor">#define</span> <span class="identifier">SEQUENCE7</span> <span class="identifier">BOOST_VMD_TYPE_NUMBER</span> 61 62<span class="identifier">BOOST_VMD_GET_TYPE</span><span class="special">(</span><span class="identifier">SEQUENCE_EMPTY</span><span class="special">)</span> <span class="identifier">will</span> <span class="keyword">return</span> <span class="identifier">BOOST_VMD_TYPE_EMPTY</span> 63<span class="identifier">BOOST_VMD_GET_TYPE</span><span class="special">(</span><span class="identifier">SEQUENCE_MULTI</span><span class="special">)</span> <span class="identifier">will</span> <span class="keyword">return</span> <span class="identifier">BOOST_VMD_TYPE_SEQUENCE</span> 64<span class="identifier">BOOST_VMD_GET_TYPE</span><span class="special">(</span><span class="identifier">SEQUENCE1</span><span class="special">)</span> <span class="identifier">will</span> <span class="keyword">return</span> <span class="identifier">BOOST_VMD_TYPE_ARRAY</span> 65<span class="identifier">BOOST_VMD_GET_TYPE</span><span class="special">(</span><span class="identifier">SEQUENCE2</span><span class="special">)</span> <span class="identifier">will</span> <span class="keyword">return</span> <span class="identifier">BOOST_VMD_TYPE_IDENTIFIER</span> 66<span class="identifier">BOOST_VMD_GET_TYPE</span><span class="special">(</span><span class="identifier">SEQUENCE3</span><span class="special">)</span> <span class="identifier">will</span> <span class="keyword">return</span> <span class="identifier">BOOST_VMD_TYPE_LIST</span> 67<span class="identifier">BOOST_VMD_GET_TYPE</span><span class="special">(</span><span class="identifier">SEQUENCE4</span><span class="special">)</span> <span class="identifier">will</span> <span class="keyword">return</span> <span class="identifier">BOOST_VMD_TYPE_NUMBER</span> 68<span class="identifier">BOOST_VMD_GET_TYPE</span><span class="special">(</span><span class="identifier">SEQUENCE5</span><span class="special">)</span> <span class="identifier">will</span> <span class="keyword">return</span> <span class="identifier">BOOST_VMD_TYPE_SEQ</span> 69<span class="identifier">BOOST_VMD_GET_TYPE</span><span class="special">(</span><span class="identifier">SEQUENCE6</span><span class="special">)</span> <span class="identifier">will</span> <span class="keyword">return</span> <span class="identifier">BOOST_VMD_TYPE_TUPLE</span> 70<span class="identifier">BOOST_VMD_GET_TYPE</span><span class="special">(</span><span class="identifier">SEQUENCE7</span><span class="special">)</span> <span class="identifier">will</span> <span class="keyword">return</span> <span class="identifier">BOOST_VMD_TYPE_TYPE</span> 71</pre> 72<h5> 73<a name="variadic_macro_data.vmd_generic.vmd_convert_sequence.h0"></a> 74 <span class="phrase"><a name="variadic_macro_data.vmd_generic.vmd_convert_sequence.usage"></a></span><a class="link" href="vmd_convert_sequence.html#variadic_macro_data.vmd_generic.vmd_convert_sequence.usage">Usage</a> 75 </h5> 76<p> 77 You can use the general header file: 78 </p> 79<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> 80</pre> 81<p> 82 or you can use the individual header file: 83 </p> 84<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">get_type</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 85</pre> 86<p> 87 for the BOOST_VMD_GET_TYPE macro. 88 </p> 89</div> 90<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 91<td align="left"></td> 92<td align="right"><div class="copyright-footer">Copyright © 2010-2017 Tropic Software 93 East Inc</div></td> 94</tr></table> 95<hr> 96<div class="spirit-nav"> 97<a accesskey="p" href="../vmd_generic.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../vmd_generic.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_assert.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 98</div> 99</body> 100</html> 101