mirror of
https://github.com/boostorg/vmd.git
synced 2026-01-19 16:52:15 +00:00
81 lines
2.7 KiB
Plaintext
81 lines
2.7 KiB
Plaintext
[/
|
|
(C) Copyright Edward Diener 2011-2015
|
|
Distributed under the Boost Software License, Version 1.0.
|
|
(See accompanying file LICENSE_1_0.txt or copy at
|
|
http://www.boost.org/LICENSE_1_0.txt).
|
|
]
|
|
|
|
[section:vmd_type 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:
|
|
|
|
* BOOST_VMD_TYPE_EMPTY, represents emptiness, ie. "empty data"
|
|
* BOOST_VMD_TYPE_ARRAY, a Boost PP array
|
|
* BOOST_VMD_TYPE_LIST, a Boost PP list
|
|
* BOOST_VMD_TYPE_SEQ, a Boost PP seq
|
|
* BOOST_VMD_TYPE_TUPLE, a Boost PP tuple
|
|
* BOOST_VMD_TYPE_IDENTIFIER, identifier
|
|
* BOOST_BMD_TYPE_NUMBER, a number
|
|
* BOOST_VMD_TYPE_TYPE, a type itself
|
|
* BOOST_VMD_TYPE_SEQUENCE, a sequence
|
|
* BOOST_VMD_TYPE_UNKNOWN, an unknown type
|
|
|
|
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:
|
|
|
|
* an identifier character, ie. an alphanumeric or an underscore
|
|
* the left parenthesis of a tuple
|
|
|
|
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.
|
|
|
|
[heading 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
|
|
|
|
[heading 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>
|
|
|
|
[endsect]
|