vmd_type.qbk 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. [section:vmd_type Types]
  8. A subset of identifiers is VMD types, called a 'v-type'. These are identifiers
  9. which represent all of the preprocessor data types which VMD can parse. This subset of
  10. identifiers is automatically registered and pre-detected by VMD. Each identifier
  11. type begins with the unique prefix 'BOOST_VMD_TYPE_'.
  12. The actual types are:
  13. * BOOST_VMD_TYPE_EMPTY, represents emptiness, ie. "empty data"
  14. * BOOST_VMD_TYPE_ARRAY, a Boost PP array
  15. * BOOST_VMD_TYPE_LIST, a Boost PP list
  16. * BOOST_VMD_TYPE_SEQ, a Boost PP seq
  17. * BOOST_VMD_TYPE_TUPLE, a Boost PP tuple
  18. * BOOST_VMD_TYPE_IDENTIFIER, identifier
  19. * BOOST_BMD_TYPE_NUMBER, a number
  20. * BOOST_VMD_TYPE_TYPE, a type itself
  21. * BOOST_VMD_TYPE_SEQUENCE, a sequence
  22. * BOOST_VMD_TYPE_UNKNOWN, an unknown type
  23. Since a v-type is itself an identifier the particular constraint on the input
  24. to test is exactly the same as for identifiers.
  25. The constraint is that the beginning input character, ignoring any whitespace, passed
  26. as the input to test must be either:
  27. * an identifier character, ie. an alphanumeric or an underscore
  28. * the left parenthesis of a tuple
  29. and if the first character is not the left parenthesis of a tuple
  30. the remaining characters must be alphanumeric or an underscore until a space character
  31. or end of input occurs.
  32. If this is not the case the behavior is undefined, and most likely
  33. a preprocessing error will occur.
  34. The macro used to test for a particular type in VMD is called BOOST_VMD_IS_TYPE.
  35. The macro takes a single parameter, the input to test against.
  36. The macro returns 1 if the parameter is a v-type, otherwise the macro returns 0.
  37. A v-type is also an identifier, which has been registered and pre-detected,
  38. so you can also use the VMD functionality which works with identifiers to work with
  39. a v-type as an identifier if you like.
  40. [heading Example]
  41. Let us look at an example of how to use BOOST_VMD_IS_TYPE.
  42. #include <boost/vmd/is_type.hpp>
  43. BOOST_VMD_IS_TYPE(input)
  44. returns:
  45. if input = BOOST_VMD_TYPE_SEQ, 1
  46. if input = BOOST_VMD_TYPE_NUMBER, 1
  47. if input = SQUARE, 0
  48. if input = BOOST_VMD_TYPE_IDENTIFIER DATA, 0 since there are tokens after the type
  49. if input = %44, does not meet the constraint therefore undefined behavior
  50. if input = ( BOOST_VMD_TYPE_EMPTY ), 0 since the macro begins with a tuple and this can be tested for
  51. [heading Usage]
  52. To use the BOOST_VMD_IS_TYPE macro either include the general header:
  53. #include <boost/vmd/vmd.hpp>
  54. or include the specific header:
  55. #include <boost/vmd/is_type.hpp>
  56. [endsect]