vmd_variadic_macros.qbk 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_vmacros Using variadic macros]
  8. Variadic macros, as specified by C++11, is a feature taken from the C99
  9. specification. They are macros which take a final parameter denoted as
  10. '...' which represents one or more final arguments to the macro as a
  11. series of comma-separated tokens. In the macro expansion a special
  12. keyword of '\_\_VA\_ARGS\_\_' represents the comma-separated tokens. This
  13. information when passed to a variadic macro I call 'variadic macro data',
  14. which gives its name to this library. The more general term 'variadic data'
  15. is used in this documentation to specify data passed to a macro which can
  16. contain any number of macro tokens as a single macro parameter, such as is
  17. found in Boost PP data types.
  18. [heading Boost support]
  19. The Boost PP library has support for variadic macros and uses its
  20. own criteria to determine if a particular compiler has that support.
  21. Boost PP defines or uses the macro BOOST_PP_VARIADICS to denote whether
  22. the compiler being used supports variadic macros. When BOOST_PP_VARIADICS
  23. is set to 1 the compiler supports variadic macros, otherwise when
  24. BOOST_PP_VARIADICS is set to 0 the compiler does not support variadic macros.
  25. If a user of Boost PP sets this value, Boost PP uses the value the end-user
  26. sets, otherwise Boost PP defines the value of BOOST_PP_VARIADICS based on its
  27. own analysis of the compiler being used. This macro can also be checked to
  28. determine if a compiler has support for variadic macros.
  29. [heading Determining variadic macro support]
  30. The VMD library automatically determines whether variadic macro support
  31. is enabled for a particular compiler by also using the same BOOST_PP_VARIADICS
  32. macro from Boost PP. The end-user of VMD can also manually
  33. set the macro BOOST_PP_VARIADICS to turn on or off compiler support for
  34. variadic macros in the VMD library. When BOOST_PP_VARIADICS is set to 0
  35. variadic macros are not supported in the VMD library, otherwise when
  36. BOOST_PP_VARIADICS is set to non-zero they are supported in the VMD library.
  37. This same macro can be used to determine if VMD supports variadic macros for a
  38. particular compiler.
  39. Since this library depends on variadic macro support, if BOOST_PP_VARIADICS
  40. is set to 0, using any of the macros in VMD will lead to a compiler error
  41. since the macro will not be defined. However just including any of the header
  42. files in VMD, even with no variadic macro support for the compiler, will not
  43. lead to any compiler errors.
  44. [endsect]