Home | Libraries | People | FAQ | More |
The macro BOOST_VMD_NUMBER looks for a v-number at the beginning of a v-sequence. Just like BOOST_VMD_IS_NUMBER it takes as a mandatory parameter a v-sequence as the first parameter. It returns a tuple of two elements. The first tuple element is the number if a v-number has been found or is an empty element if a v-number has not been found. The second tuple element is the rest of the v-sequence if a v-number has been found or an empty element if no v-number has been found. Since a v-number can be found and the rest of the v-sequence can be empty, one always needs to check the first tuple element to determine if the v-number was found at the beginning of the v-sequence or not.
To use the BOOST_VMD_NUMBER macro either include the general header:
#include <boost/vmd/vmd.hpp>
or include the specific header:
#include <boost/vmd/number.hpp>
A beginning v-number in a v-sequence can always be parsed using just the mandatory v-sequence parameter if the v-number is followed by:
A 'tuple' here refers to any pair of parenthesis, such as an array, a list, or the beginning of a seq.
As we will see more complicated v-sequences beginning with a v-number can be parsed using the optional parameters of BOOST_VMD_NUMBER. These optional parameters will be discussed later.
Some examples:
#define SOME_INPUT_N1 234 (tupe1,tupe2) BOOST_VMD_NUMBER(SOME_INPUT_N1)
expands to (234,(tupe1,tupe2))
#define SOME_INPUT_N2 147 BOOST_VMD_NUMBER(SOME_INPUT_N2)
expands to (147,)
#define SOME_INPUT_N3 5 (seq1)(seq2) 47 BOOST_VMD_NUMBER(SOME_INPUT_N3)
expands to (5,(seq1)(seq2) 47)
#define SOME_INPUT_N4 name 227 BOOST_VMD_NUMBER(SOME_INPUT_N4)
expands to (,) since the v-sequence does not beginning with a v-number
#define SOME_INPUT_N5 79 120 (tupe1,tupe2) #define SOME_INPUT_N6 79 name (tupe1,tupe2) BOOST_VMD_NUMBER(SOME_INPUT_N5) BOOST_VMD_NUMBER(SOME_INPUT_N6)
either one expands to (,) since the beginning number is not followed by a tuple or end-of-sequence.
See the next topic for how to parse this last example using the optional parameters of BOOST_VMD_NUMBER.