Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Boost PP data types

VMD is able to determine whether or not preprocessing input is a given Boost PP data type. The VMD macros to do this are:

Each of these macros take a single parameter as input and return 1 if the parameter is the appropriate data type and 0 if it is not.

One thing to realize is that both an array and a non-empty list are also a tuple. So if one has:

#define ANARRAY (3,(a,b,c))
#define ALIST (a,(b,(c,BOOST_PP_NIL)))
#define ATUPLE (a,b,c)
#define ASEQ (a)(b)(c)

then

BOOST_VMD_IS_TUPLE(ANARRAY) returns 1
BOOST_VMD_IS_TUPLE(ALIST) returns 1
BOOST_VMD_IS_TUPLE(ATUPLE) returns 1
BOOST_VMD_IS_TUPLE(ASEQ) returns 0

Another thing to realize is that a single element tuple is also a one element seq. So if one has:

#define ASE_TUPLE (a)

then

BOOST_VMD_IS_TUPLE(ASE_TUPLE) returns 1
BOOST_VMD_IS_SEQ(ASE_TUPLE) returns 1

Unlike the processing of v-identifiers or v-numbers, there is no constraint about the beginning of the input causing a preprocessing error since preprocessor concatenation is not used to determine any of these data types.

Usage

You can use the geneal header file:

#include <boost/vmd/vmd.hpp>

or you can use individual header files for each of these macros. The individual header files are:

#include <boost/vmd/array.hpp> //  for the BOOST_VMD_IS_ARRAY macro
#include <boost/vmd/list.hpp> //  for the BOOST_VMD_IS_LIST macro
#include <boost/vmd/seq.hpp> //  for the BOOST_VMD_IS_SEQ macro
#include <boost/vmd/tuple.hpp> // for the BOOST_VMD_IS_TUPLE macro.

PrevUpHomeNext