From de4967645230f7e174575aa31738e4abf4593d50 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Sat, 2 Nov 2019 18:59:55 -0400 Subject: [PATCH] Added docs for the BOOST_PP_VA_OPT macro. --- doc/headers.html | 2 + doc/headers/facilities/va_opt.html | 32 ++++++++ doc/ref.html | 1 + doc/ref/va_opt.html | 124 +++++++++++++++++++++++++++++ 4 files changed, 159 insertions(+) create mode 100644 doc/headers/facilities/va_opt.html create mode 100644 doc/ref/va_opt.html diff --git a/doc/headers.html b/doc/headers.html index 651de5b..543667e 100644 --- a/doc/headers.html +++ b/doc/headers.html @@ -88,6 +88,8 @@
  • intercept.hpp
  • overload.hpp (v)
  • +
  • va_opt.hpp + (v)
  • for.hpp*
  • identity.hpp*
  • if.hpp*
  • diff --git a/doc/headers/facilities/va_opt.html b/doc/headers/facilities/va_opt.html new file mode 100644 index 0000000..5e6c8fa --- /dev/null +++ b/doc/headers/facilities/va_opt.html @@ -0,0 +1,32 @@ + + + + + facilities/va_opt.hpp + + + +
    The facilities/va_opt.hpp + header defines a variadic macro for the C++20 level that offers a + more flexible alternative to the __VA_OPT__ construct.
    +

    Usage

    +
    #include <boost/preprocessor/facilities/va_opt.hpp> +
    +

    Contents

    + +
    +
    © 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)

    +
    + + diff --git a/doc/ref.html b/doc/ref.html index a627296..f5328e6 100644 --- a/doc/ref.html +++ b/doc/ref.html @@ -296,6 +296,7 @@
  • UPDATE_COUNTER
  • +
  • VA_OPT (v)
  • VALUE
  • VARIADICS
  • VARIADIC_ELEM (v)
  • diff --git a/doc/ref/va_opt.html b/doc/ref/va_opt.html new file mode 100644 index 0000000..694ba27 --- /dev/null +++ b/doc/ref/va_opt.html @@ -0,0 +1,124 @@ + + + + + BOOST_PP_VA_OPT + + + +
    The BOOST_PP_VA_OPT variadic + macro is a more flexible alternative to the C++20 __VA_OPT__ + construct. It expands to either one of two inputs depending on + whether the variadic data is empty or not, whereas the C++20 + __VA_OPT__ constructs expands to either its input or nothing + depending on whether the variadic data is empty or not. This macro + only exists when the compilation is at the C++20 level and the + __VA_OPT__ construct is supported.
    +

    Usage

    +
    BOOST_PP_VA_OPT(x,y,...) (v)
    +
    +

    Arguments

    +

          x
    +           A tuple + whose data is the macro expansion if the variadic data is + not empty
    +       y
    +           A tuple + whose data is the macro expansion if the variadic data is + empty
    +       ,,,
    +           The variadic + data to be checked for emptiness
    +

    +
    +
    +

    Remarks

    +
    When the macro invocation BOOST_PP_VARIADIC_HAS_OPT() expands + to 1, then this macro exists and can be invoked, otherwise this + macro does not exist and attempting to invoke it will lead to a + preprocessor error that the macro can not be found. Because of + this condition the header file for including this macro includes + the header file for the BOOST_PP_VARIADIC_HAS_OPT macro.
    +
    + The difference between this macro and the __VA_OPT__ construct + illustrates a limitation of the latter construct with a trade off + of simpler syntax. The differences between the __VA_OPT__ + construct and this macro are:
    + +
    + The exact BOOST_PP_VA_OPT equivalent to the construct of  + '__VA_OPT__ ( pp-tokens )' in the replacement list of a macro is + 'BOOST_PP_VA_OPT (( pp-tokens ),(),__VA_ARGS__)'.
    +

    See Also

    + +

    Requirements

    +
    Header:  <boost/preprocessor/facilities/va_opt.hpp> +
    +

    Sample Code

    +
    +
    #include <boost/preprocessor/facilities/va_opt.hpp>
    +
    +# if BOOST_PP_VARIADIC_HAS_OPT()
    +
    +#define DATA
    +#define OBJECT OBJECT2
    +#define OBJECT2
    +#define FUNC(x) FUNC2(x)
    +#define FUNC2(x)
    +#define FUNC_GEN(x,y) (1,2,3)
    +
    +BOOST_PP_VA_OPT((1),(2),DATA)                      // expands to 2
    +BOOST_PP_VA_OPT((3),(4),OBJECT)                    // expands to 4
    +BOOST_PP_VA_OPT((5),(6),FUNC(1))                   // expands to 6
    +BOOST_PP_VA_OPT((7,8),(9,10),FUNC)                 // expands to 7,8
    +BOOST_PP_VA_OPT((1,2,3,4,5),(6,7,8,9,10),FUNC_GEN) // expands to 1,2,3,4,5
    +
    +#endif
    +
    +
    +
    +
    © 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)

    +
    + +