forked from boostorg/preprocessor
Updated doc doe BOOST_PP_OVERLOAD.
This commit is contained in:
@ -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> <a href="../headers/facilities/overload.html"><boost/preprocessor/facilities/overload.hpp></a>
|
<div> <b>Header:</b> <a
|
||||||
|
href="../headers/facilities/overload.html"><boost/preprocessor/facilities/overload.hpp></a>
|
||||||
</div>
|
</div>
|
||||||
<h4>Sample Code</h4>
|
<h4>Sample Code</h4>
|
||||||
<div>
|
<div>
|
||||||
<pre>#include <<a href="../headers/facilities/overload.html">boost/preprocessor/facilities/overload.hpp</a>><br>#include <<a
|
<pre>#include <<a href="../headers/facilities/overload.html">boost/preprocessor/facilities/overload.hpp</a>><br>#include <<a 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 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 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
|
|
||||||
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
|
|
||||||
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>
|
|
||||||
</div>
|
</div>
|
||||||
<hr size="1">
|
<hr size="1">
|
||||||
<div style="margin-left: 0px;"> <i></i><i><EFBFBD> Copyright Edward Diener 2011,2013,2016</i> </div>
|
<div style="margin-left: 0px;"> <i></i><i><EFBFBD> Copyright Edward Diener
|
||||||
|
2011,2013,2016</i> </div>
|
||||||
<div style="margin-left: 0px;">
|
<div style="margin-left: 0px;">
|
||||||
<p><small>Distributed under the Boost Software License, Version 1.0.
|
<p><small>Distributed under the Boost Software License, Version
|
||||||
|
1.0.
|
||||||
(See accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a>
|
(See accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a>
|
||||||
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
|
or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</small></p>
|
||||||
</div>
|
</div>
|
||||||
|
</body>
|
||||||
</body></html>
|
</html>
|
||||||
|
@ -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,18 +159,20 @@
|
|||||||
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>
|
||||||
|
Reference in New Issue
Block a user