Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

Getting the type of data

VMD has the ability to retrieve the type of any data which it can parse, which means any VMD sequence. The macro to do this is called BOOST_VMD_GET_TYPE and it takes a single required parameter, which is a VMD sequence.

It returns one of the types previously discussed when introducing v-types as an identifier subset. As explained previously in that topic a v-type is fully recognized by VMD macros and can be part of a sequence and passed as VMD data just like all the other data types VMD recognizes.

When BOOST_VMD_GET_TYPE returns the type of data it returns by default the most specific type that the data can be. This means that non-empty lists and arrays are returned as such, not as tuples, and numbers and types and empty lists are returned as such, not as identifiers.

#include <boost/vmd/get_type.hpp>

#define BOOST_VMD_REGISTER_ANID (ANID)
#define SEQUENCE_EMPTY
#define SEQUENCE_MULTI (1,2,3) 88
#define SEQUENCE1 (3,(1,2,3))
#define SEQUENCE2 ANID
#define SEQUENCE3 (1,(2,(3,BOOST_PP_NIL)))
#define SEQUENCE4 1
#define SEQUENCE5 (1)(2)(3)
#define SEQUENCE6 (1,2,3)
#define SEQUENCE7 BOOST_VMD_TYPE_NUMBER

BOOST_VMD_GET_TYPE(SEQUENCE_EMPTY) will return BOOST_VMD_TYPE_EMPTY
BOOST_VMD_GET_TYPE(SEQUENCE_MULTI) will return BOOST_VMD_TYPE_SEQUENCE
BOOST_VMD_GET_TYPE(SEQUENCE1) will return BOOST_VMD_TYPE_ARRAY
BOOST_VMD_GET_TYPE(SEQUENCE2) will return BOOST_VMD_TYPE_IDENTIFIER
BOOST_VMD_GET_TYPE(SEQUENCE3) will return BOOST_VMD_TYPE_LIST
BOOST_VMD_GET_TYPE(SEQUENCE4) will return BOOST_VMD_TYPE_NUMBER
BOOST_VMD_GET_TYPE(SEQUENCE5) will return BOOST_VMD_TYPE_SEQ
BOOST_VMD_GET_TYPE(SEQUENCE6) will return BOOST_VMD_TYPE_TUPLE
BOOST_VMD_GET_TYPE(SEQUENCE7) will return BOOST_VMD_TYPE_TYPE
Usage

You can use the general header file:

#include <boost/vmd/vmd.hpp>

or you can use the individual header file:

#include <boost/vmd/get_type.hpp>

for the BOOST_VMD_GET_TYPE macro.


PrevUpHomeNext