variadic_has_opt.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <html>
  2. <head>
  3. <title>BOOST_PP_VARIADIC_HAS_OPT</title>
  4. <link rel="stylesheet" type="text/css" href="../styles.css">
  5. </head>
  6. <body>
  7. <div style="margin-left: 0px;"> The <b>BOOST_PP_VARIADIC_HAS_OPT</b> macro
  8. determines whether or not the C++20 __VA_OPT__ construct is supported for the compiler's preprocessor being used.
  9. Expands to 1 if the __VA_OPT__ construct is supported, otherwise expands to 0.
  10. </div>
  11. <h4>Usage</h4>
  12. <div class="code"> <b>BOOST_PP_VARIADIC_HAS_OPT</b>() <br>
  13. </div>
  14. <h4>Arguments</h4>
  15. <dl>
  16. <dt>None<br>
  17. </dt>
  18. </dl>
  19. <h4>Remarks</h4>
  20. <div>
  21. This macro only returns 1 if the compiler is compiling at its own C++20 level and
  22. __VA_OPT__ is supported. It is possible for a compiler to support the __VA_OPT__
  23. construct when not compiling at its own C++20 level, but this macro will return
  24. 0 in that case even if __VA_OPT__ is normally supported for that level. The reason
  25. for this is that such a compiler may have a compiler switch, enforcing a strict
  26. adherence to a particular C++ standard level, which gives a warning or an error
  27. if __VA_OPT__ is specified below the C++20 level, and the preprocessor library
  28. wants to avoid that happening. Therefore the macro will only test to see whether
  29. or not __VA_OPT__ is supported at the C++20 level, while otherwise always returning
  30. 0 for all lesser C++ standard levels.
  31. </div>
  32. <h4>Requirements</h4>
  33. <div> <b>Header:</b> &nbsp;<a href="../headers/variadic/has_opt.html">&lt;boost/preprocessor/variadic/has_opt.hpp&gt;</a>
  34. </div>
  35. <h4>Sample Code</h4>
  36. <div>
  37. <pre>
  38. #include &lt;<a href="../headers/variadic/has_opt.html">boost/preprocessor/variadic/has_opt.hpp</a>&gt;<br>
  39. #if <a href="variadic_has_opt.html">BOOST_PP_VARIADIC_HAS_OPT</a>()
  40. // Preprocessor code which uses __VA_OPT__
  41. #else
  42. // Preprocessor code which does not use __VA_OPT__
  43. #endif
  44. </pre>
  45. <br>
  46. or within a macro definition<br><br>
  47. <pre>
  48. #include &lt;boost/preprocessor/control/iif.hpp&gt;
  49. #include &lt;<a href="../headers/variadic/has_opt.html">boost/preprocessor/variadic/has_opt.hpp</a>&gt;<br>
  50. #define USE_OPT(...) BOOST_PP_IIF(<a href="variadic_has_opt.html">BOOST_PP_VARIADIC_HAS_OPT</a>(),MACRO_USING_OPT,MACRO_NOT_USING_OPT)(__VA_ARGS__)
  51. #define MACRO_USING_OPT(...) __VA_OPT__( preprocessor tokens ) anything
  52. #define MACRO_NOT_USING_OPT(...) anything
  53. </pre>
  54. </div>
  55. <hr size="1">
  56. <div style="margin-left: 0px;"> <i></i><i>© Copyright Edward Diener 2019</i> </div>
  57. <div style="margin-left: 0px;">
  58. <p><small>Distributed under the Boost Software License, Version 1.0.
  59. (See accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a>
  60. or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
  61. </div>
  62. </body>
  63. </html>