Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Types

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_'.

The actual types are:

Since a v-type is itself an identifier the particular constraint on the input to test is exactly the same as for identifiers.

The constraint is that the beginning input character, ignoring any whitespace, passed as the input to test must be either:

and if the first character is not the left parenthesis of a tuple the remaining characters must be alphanumeric until a space character or end of input occurs.

If this is not the case the behavior is undefined, and most likely a preprocessing error will occur.

Given the input:

s_anything : can be tested
S_anything : can be tested
s_anYthiNg : can be tested
s&_anYthiNg : can be tested
_anything : can be tested
_Anything : can be tested
_anytH?Ing : can be tested
BOOST_VMD_TYPE_NUMBER : can be tested
BOOST_VMD_TYPE_TUPLE245e2: can be tested
(anything) : can be tested, tuple
(anything) anything : can be tested, tuple + identifier
anything anything : can be tested, identifier followed by space character

%_anything : undefined behavior and most likely a preprocessing error due to the constraint
(_anything : undefined behavior and most likely a preprocessing error due to the constraint, since a single '(' does not form a tuple
44.3 : undefined behavior and most likely a preprocessing error due to the constraint since '.' is not alphanumeric

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.

The macro returns 1 if the parameter is a v-type, otherwise the macro returns 0.

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.

Example

Let us look at an example of how to use BOOST_VMD_IS_TYPE.

#include <boost/vmd/is_type.hpp>

BOOST_VMD_IS_TYPE(input)

returns:

if input = BOOST_VMD_TYPE_SEQ, 1
if input = BOOST_VMD_TYPE_NUMBER, 1
if input = SQUARE, 0
if input = BOOST_VMD_TYPE_IDENTIFIER DATA, 0 since there are tokens after the type
if input = %44, does not meet the constraint therefore undefined behavior
if input = ( BOOST_VMD_TYPE_EMPTY ), 0 since the macro begins with a tuple and this can be tested for
Usage

To use the BOOST_VMD_IS_TYPE macro either include the general header:

#include <boost/vmd/vmd.hpp>

or include the specific header:

#include <boost/vmd/is_type.hpp>

PrevUpHomeNext