Updated doc doe BOOST_PP_OVERLOAD.

This commit is contained in:
Edward Diener
2020-07-03 14:18:44 -04:00
parent e231fe7ad9
commit 5c7ae49828
2 changed files with 56 additions and 48 deletions

View File

@@ -1,17 +1,19 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> <html>
<head> <head>
<meta content="text/html; charset=windows-1252" http-equiv="content-type"> <meta content="text/html; charset=windows-1252"
http-equiv="content-type">
<title>BOOST_PP_OVERLOAD</title> <title>BOOST_PP_OVERLOAD</title>
<link rel="stylesheet" type="text/css" href="../styles.css"> <link rel="stylesheet" type="text/css" href="../styles.css">
</head> </head>
<body> <body>
<div style="margin-left: 0px;"> The <b>BOOST_PP_OVERLOAD</b> variadic <div style="margin-left: 0px;"> The <b>BOOST_PP_OVERLOAD</b>
macro expands to the name of a non-variadic macro having a given number of variadic macro expands to the name of a non-variadic macro having
parameters.<br> a given number of parameters.<br>
</div> </div>
<h4>Usage</h4> <h4>Usage</h4>
<div class="code"> <b>BOOST_PP_OVERLOAD</b>(<i>prefix</i>,...) <a href="../topics/variadic_macros.html#VNotation" <div class="code"> <b>BOOST_PP_OVERLOAD</b>(<i>prefix</i>,...) <a
target="_self"><sup>(v)</sup></a><br> href="../topics/variadic_macros.html#VNotation" target="_self"><sup>(v)</sup></a><br>
</div> </div>
<h4>Arguments</h4> <h4>Arguments</h4>
<dl> <dl>
@@ -20,39 +22,43 @@
<dd> The prefix of the non-variadic macro name. </dd> <dd> The prefix of the non-variadic macro name. </dd>
<dt>...<br> <dt>...<br>
</dt> </dt>
<dd><i> Variadic data</i>. The number of variadic data <dd><i> Variadic data</i>. The number of variadic data elements,
elements, as determined by BOOST_PP_VARIADIC_SIZE, is appended to the as determined by BOOST_PP_VARIADIC_SIZE, is appended to the
prefix to form the output non-variadic macro name.<br> prefix to form the output non-variadic macro name.<br>
</dd> </dd>
</dl> </dl>
<h4>Remarks</h4> <h4>Remarks</h4>
<div> This macro creates a macro name which depends on the number of <div> This macro creates a macro name which depends on the number of
elements of variadic data. It should be used in the form of <br> elements of variadic data. It should be used in the form of <br>
BOOST_PP_OVERLOAD(MACRO_NAME_,__VA_ARGS__)(__VA_ARGS__) in order to BOOST_PP_OVERLOAD(MACRO_NAME_,__VA_ARGS__)(__VA_ARGS__) in order
call a non-variadic macro taking a given number of variadic data to call a non-variadic macro taking a given number of variadic
elements as non-variadic arguments. In this way one can invoke a data elements as non-variadic arguments. In this way one can
variadic macro with a variable number of parameters which calls one of invoke a variadic macro with a variable number of parameters which
a series of non-variadic macros doing very similar things. calls one of a series of non-variadic macros doing very similar
things.<br>
<br>
In <a
href="file:///E:/Programming/VersionControl/modular-boost/libs/preprocessor/doc/topics/variadic_macros.html#C20_Support_For_Variadic_Macros">C++
20</a> mode the <i>variadic</i> <i>data</i> can be empty and
the given number of parameters will be 0.<br>
</div> </div>
<b>Requirements</b> <b>Requirements</b>
<div> <b>Header:</b> &nbsp;<a href="../headers/facilities/overload.html">&lt;boost/preprocessor/facilities/overload.hpp&gt;</a> <div> <b>Header:</b> &nbsp;<a
href="../headers/facilities/overload.html">&lt;boost/preprocessor/facilities/overload.hpp&gt;</a>
</div> </div>
<h4>Sample Code</h4> <h4>Sample Code</h4>
<div> <div>
<pre>#include &lt;<a href="../headers/facilities/overload.html">boost/preprocessor/facilities/overload.hpp</a>&gt;<br>#include <<a <pre>#include &lt;<a href="../headers/facilities/overload.html">boost/preprocessor/facilities/overload.hpp</a>&gt;<br>#include &lt;<a href="../headers/cat.html">boost/preprocessor/cat.hpp</a>&gt;<br>#include &lt;<a href="../headers/facilities/empty.html">boost/preprocessor/facilities/empty.hpp</a>&gt;<br>#include &lt;<a href="../headers/arithmetic/add.html">boost/preprocessor/arithmetic/add.hpp</a>&gt;<br><br>#define MACRO_1(number) MACRO_2(number,10)<br>#define MACRO_2(number1,number2) <a href="add.html">BOOST_PP_ADD</a>(number1,number2)<br><br>#if !BOOST_PP_VARIADICS_MSVC<br><br>#define MACRO_ADD_NUMBERS(...) <a href="overload.html">BOOST_PP_OVERLOAD</a>(MACRO_,__VA_ARGS__)(__VA_ARGS__)<br><br>#else<br><br>// or for Visual C++<br><br>#define MACRO_ADD_NUMBERS(...) \<br> <a href="cat.html">BOOST_PP_CAT</a>(<a href="overload.html">BOOST_PP_OVERLOAD</a>(MACRO_,__VA_ARGS__)(__VA_ARGS__),<a href="empty.html">BOOST_PP_EMPTY</a>())<br><br>#endif<br><br>MACRO_ADD_NUMBERS(5) // output is 15<br>MACRO_ADD_NUMBERS(3,6) // output is 9</pre>
href="../headers/cat.html">boost/preprocessor/cat.hpp</a>><br>#include <<a href="../headers/facilities/empty.html">boost/preprocessor/facilities/empty.hpp</a>><br>#include <<a </div>
href="../headers/arithmetic/add.html">boost/preprocessor/arithmetic/add.hpp</a>><br><br>#define MACRO_1(number) MACRO_2(number,10)<br>#define MACRO_2(number1,number2) <a <hr size="1">
href="add.html">BOOST_PP_ADD</a>(number1,number2)<br><br>#if !BOOST_PP_VARIADICS_MSVC<br><br>#define MACRO_ADD_NUMBERS(...) <a <div style="margin-left: 0px;"> <i></i><i><EFBFBD> Copyright Edward Diener
href="overload.html">BOOST_PP_OVERLOAD</a>(MACRO_,__VA_ARGS__)(__VA_ARGS__)<br><br>#else<br><br>// or for Visual C++<br><br>#define MACRO_ADD_NUMBERS(...) \<br> <a 2011,2013,2016</i> </div>
href="cat.html">BOOST_PP_CAT</a>(<a href="overload.html">BOOST_PP_OVERLOAD</a>(MACRO_,__VA_ARGS__)(__VA_ARGS__),<a <div style="margin-left: 0px;">
href="empty.html">BOOST_PP_EMPTY</a>())<br><br>#endif<br><br>MACRO_ADD_NUMBERS(5) // output is 15<br>MACRO_ADD_NUMBERS(3,6) // output is 9</pre> <p><small>Distributed under the Boost Software License, Version
</div> 1.0.
<hr size="1"> (See accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a>
<div style="margin-left: 0px;"> <i></i><i><EFBFBD> Copyright Edward Diener 2011,2013,2016</i> </div> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
<div style="margin-left: 0px;"> </div>
<p><small>Distributed under the Boost Software License, Version 1.0. </body>
(See accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> </html>
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
</div>
</body></html>

View File

@@ -1,4 +1,4 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> <html>
<head> <head>
<meta content="text/html; charset=windows-1252" <meta content="text/html; charset=windows-1252"
@@ -141,8 +141,8 @@
<div> In the C++20 specification there is a new construct which can <div> In the C++20 specification there is a new construct which can
be used in the expansion of a variadic macro, called __VA_OPT__. be used in the expansion of a variadic macro, called __VA_OPT__.
This construct when used in the expansion of a variadic macro is This construct when used in the expansion of a variadic macro is
followed by an opening paranthesis ('('), preprocessor data, and a followed by an opening paranthesis '(', preprocessor data, and a
closing parenthesis ('}'). When the variadic data passed by the closing parenthesis ')'. When the variadic data passed by the
invocation of a variadic macro is empty, this new construct invocation of a variadic macro is empty, this new construct
expands to nothing. When the variadic data passed by the expands to nothing. When the variadic data passed by the
invocation of a variadic macro is not empty, this new construct invocation of a variadic macro is not empty, this new construct
@@ -159,21 +159,23 @@
it returns 0. <br> it returns 0. <br>
<br> <br>
When the __VA_OPT__ construct is supported in C++20 mode the When the __VA_OPT__ construct is supported in C++20 mode the
variadic data passed to the variadic macros can be empty, variadic data passed to the variadic macros and to
otherwise when not in this mode variadic data passed to the BOOST_PP_OVERLOAD can be empty, otherwise when not in this mode
variadic macros should never be empty. In this C+++20 mode variadic data passed to the variadic macros should never be empty.
invoking BOOST_PP_VARIADIC_SIZE with empty data expands to 0, In this C+++20 mode invoking BOOST_PP_VARIADIC_SIZE with empty
invoking BOOST_PP_VARIADIC_TO_ARRAY with empty data expands to the data expands to 0, invoking BOOST_PP_VARIADIC_TO_ARRAY with empty
empty array '(0,())', and invoking BOOST_PP_VARIADIC_TO_LIST with data expands to the empty array '(0,())', invoking
empty data expands to the empty list 'BOOST_PP_NIL'. Similarly in BOOST_PP_VARIADIC_TO_LIST with empty data expands to the empty
this C++20 mode passing an empty array '(0,())' to list 'BOOST_PP_NIL', and invoking BOOST_PP_OVERLOAD with empty
BOOST_PP_ARRAY_ENUM expands to empty variadic data and passing an data creates an overload name with 0 appended. Similarly in this
empty list 'BOOST_PP_NIL' to BOOST_PP_LIST_ENUM also expands to C++20 mode passing an empty array '(0,())' to BOOST_PP_ARRAY_ENUM
empty variadic data. Neither a seq or a tuple can be empty so expands to empty variadic data and passing an empty list
passing empty variadic data to either BOOST_PP_VARIADIC_TO_SEQ or 'BOOST_PP_NIL' to BOOST_PP_LIST_ENUM also expands to empty
variadic data. Neither a seq or a tuple can be empty so passing
empty variadic data to either BOOST_PP_VARIADIC_TO_SEQ or
BOOST_PP_VARIADIC_TO_TUPLE is erroneous. Likewise passing empty BOOST_PP_VARIADIC_TO_TUPLE is erroneous. Likewise passing empty
data to BOOST_PP_VARIADIC_ELEM is always erroneous since there are data to BOOST_PP_VARIADIC_ELEM is always erroneous since there are
no tokens of variadic data to access. <br> no tokens of variadic data to access.<br>
</div> </div>
<u style="font-weight: bold;"> Using a Tuple Instead of an Array<br> <u style="font-weight: bold;"> Using a Tuple Instead of an Array<br>
</u> </u>