]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/vmd/doc/vmd_number.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / vmd / doc / vmd_number.qbk
CommitLineData
7c673cae
FG
1[/
2 (C) Copyright Edward Diener 2011-2015
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt).
6]
7
8[section:vmd_number Numbers]
9
10A number in VMD is a preprocessing 'pp-number',
11limited to a Boost PP number. This is an integral literal between 0 and 256.
12The form of the number does not contain leading zeros. Acceptable as numbers are:
13
14 0
15 127
16 33
17 254
18 18
19
20but not:
21
22 033
23 06
24 009
25 00
26
27[heading Problem testing any number]
28
29As can be seen from the explanation of an identifier, a number is merely
30a small subset of all possible identifiers, for which VMD internally provides
31registration macros for its use and pre-detection macros for its use. Therefore the particular
32constraint on the input to test is exactly the same as for identifiers.
33
34The constraint is that the beginning input character, ignoring any whitespace, passed
35as the input to test must be either:
36
37* an identifier character, ie. an alphanumeric or an underscore
38* the left parenthesis of a tuple
39
40and if the first character is not the left parenthesis of a tuple
41the remaining characters must be alphanumeric or an underscore until a space character
42or end of input occurs.
43
44If this is not the case the behavior is undefined, and most likely
45a preprocessing error will occur.
46
47[heading Testing for a number macro]
48
49The macro used to test for any number in VMD is called BOOST_VMD_IS_NUMBER.
50The macro takes a single parameter, the input to test against.
51
52The macro returns 1 if the parameter is a Boost PP number, otherwise the macro returns 0.
53
54The Boost PP library has a great amount of functionality for working with numbers,
55so once you use VMD to parse/test for a number you can use Boost PP to work with that
56number in various ways. The VMD makes no attempt to duplicate the functionality
57of numbers that in the Boost PP library.
58
59Any number is also an identifier, which has been registered and pre-detected,
60so you can also use the VMD functionality which works with identifiers to work with
61a number as an identifier if you like.
62
63[heading Example]
64
65Let us look at an example of how to use BOOST_VMD_IS_NUMBER.
66
67 #include <boost/vmd/is_number.hpp>
68
69 BOOST_VMD_IS_NUMBER(input)
70
71 returns:
72
73 if input = 0, 1
74 if input = 44, 1
75 if input = SQUARE, 0
76 if input = 44 DATA, 0 since there are tokens after the number
77 if input = 044, 0 since no leading zeros are allowed for our Boost PP numbers
78 if input = 256, 1
79 if input = 257, 0 since it falls outside the Boost PP number range of 0-256
80 if input = %44, does not meet the constraint therefore undefined behavior
81 if input = 44.0, does not meet the constraint therefore undefined behavior
82 if input = ( 44 ), 0 since the macro begins with a tuple and this can be tested for
83
84[heading Usage]
85
86To use the BOOST_VMD_IS_NUMBER macro either include the general header:
87
88 #include <boost/vmd/vmd.hpp>
89
90or include the specific header:
91
92 #include <boost/vmd/is_number.hpp>
93
94[endsect]