The BOOST_PP_VARIADIC_OPT macro determines whether or not the C++20 __VA_OPT__ construct is supported for the compiler's preprocessor being used. Expands to 1 if the __VA_OPT__ construct is supported, otherwise expands to 0.

Usage

BOOST_PP_VARIADIC_OPT()

Arguments

None

Requirements

Header:  <boost/preprocessor/variadic/opt.hpp>

Sample Code

#include <boost/preprocessor/variadic/opt.hpp>
#if BOOST_PP_VARIADIC_OPT() // Preprocessor code which uses __VA_OPT__ #else // Preprocessor code which does not use __VA_OPT__ #endif

or within a macro definition

#include <boost/preprocessor/control/iif.hpp>
#include <boost/preprocessor/variadic/opt.hpp>
#define USE_OPT(...) BOOST_PP_IIF(BOOST_PP_VARIADIC_OPT(),MACRO_USING_OPT,MACRO_NOT_USING_OPT)(__VA_ARGS__) #define MACRO_USING_OPT(...) __VA_OPT__( preprocessor tokens ) anything #define MACRO_NOT_USING_OPT(...) anything

© Copyright Edward Diener 2019

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt)