forked from boostorg/preprocessor
Updated example for using the BOOST_PP_VARIADIC_OPT macro.
This commit is contained in:
@ -23,11 +23,20 @@ Expands to 1 if the __VA_OPT__ construct is supported, otherwise expands to 0.
|
|||||||
<div>
|
<div>
|
||||||
<pre>
|
<pre>
|
||||||
#include <<a href="../headers/variadic/opt.html">boost/preprocessor/variadic/opt.hpp</a>><br>
|
#include <<a href="../headers/variadic/opt.html">boost/preprocessor/variadic/opt.hpp</a>><br>
|
||||||
#if <a href="variadic_opt.html">BOOST_PP_VARIADIC_OPT</a>()<br>
|
#if <a href="variadic_opt.html">BOOST_PP_VARIADIC_OPT</a>()
|
||||||
// Preprocessor code which uses __VA_OPT__<br>
|
// Preprocessor code which uses __VA_OPT__
|
||||||
#else<br>
|
#else
|
||||||
// Preprocessor code which does not use __VA_OPT__<br>
|
// Preprocessor code which does not use __VA_OPT__
|
||||||
#endif<br>
|
#endif
|
||||||
|
</pre>
|
||||||
|
<br>
|
||||||
|
or within a macro definition<br><br>
|
||||||
|
<pre>
|
||||||
|
#include <boost/preprocessor/control/iif.hpp>
|
||||||
|
#include <<a href="../headers/variadic/opt.html">boost/preprocessor/variadic/opt.hpp</a>><br>
|
||||||
|
#define USE_OPT(...) BOOST_PP_IIF(<a href="variadic_opt.html">BOOST_PP_VARIADIC_OPT</a>(),MACRO_USING_OPT,MACRO_NOT_USING_OPT)(__VA_ARGS__)
|
||||||
|
#define MACRO_USING_OPT(...) __VA_OPT__( preprocessor tokens ) anything
|
||||||
|
#define MACRO_NOT_USING_OPT(...) anything
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<hr size="1">
|
<hr size="1">
|
||||||
|
Reference in New Issue
Block a user