Difference between revisions of "cpp/utility/variadic/va start"
From cppreference.com
m (fmt.) |
Andreas Krug (Talk | contribs) m (fmt) |
||
Line 1: | Line 1: | ||
{{ctitle|va_start}} | {{ctitle|va_start}} | ||
{{cpp/utility/variadic/navbar}} | {{cpp/utility/variadic/navbar}} | ||
− | {{ddcl|header = cstdarg| | + | {{ddcl|header=cstdarg| |
void va_start( std::va_list ap, parm_n ); | void va_start( std::va_list ap, parm_n ); | ||
}} | }} |
Revision as of 02:12, 26 October 2023
Defined in header <cstdarg>
|
||
void va_start( std::va_list ap, parm_n ); |
||
The va_start
macro enables access to the variable arguments following the named argument parm_n.
va_start
should be invoked with an instance to a valid va_list object ap before any calls to va_arg.
If the parm_n is a pack expansion or an entity resulting from a lambda capture, the program is ill-formed, no diagnostic required. |
(since C++11) |
If parm_n is declared with reference type or with a type not compatible with the type that results from default argument promotions, the behavior is undefined.
Contents |
Parameters
ap | - | an instance of the va_list type |
parm_n | - | the named parameter preceding the first variable parameter |
Expanded value
(none)
Notes
va_start
is required to support parm_n with overloaded operator&
.
Example
Run this code
Output:
150
Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
CWG 273 | C++98 | va_start may not work if unary operator& is overloaded
|
required to work correctly even if operator& is overloaded
|
See also
accesses the next variadic function argument (function macro) | |
ends traversal of the variadic function arguments (function macro) | |
C documentation for va_start
|