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 or an underscore 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.
The macro used to test for a particular type in VMD is called BOOST_VMD_IS_TYPE. The macro takes a single variadic 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.
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
To use the BOOST_VMD_IS_TYPE macro either include the general header:
or include the specific header: