Variadic arguments

Allows a function to accept any number of extra arguments.

# Notes

In the C programming language until C23, at least one named parameter must appear before the ellipsis parameter, so R printz(…); is not valid until C23. In C++, this form is allowed even though the arguments passed to such function are not accessible, and is commonly used as the fallback overload in SFINAE, exploiting the lowest priority of the ellipsis conversion in overload resolution.

This syntax for variadic arguments was introduced in 1983 C++ without the comma before the ellipsis. When C89 adopted function prototypes from C++, it replaced the syntax with one requiring the comma. For compatibility, C++98 accepts both C++-style f(int n…) and C-style f(int n, …). The original C++-style grammar is deprecated since C++26.

The comma can be used in abbreviated function templates to make the ellipsis signify a variadic function instead of a variadic template:

void f1(auto…); // same as template<class… Ts> void f3(Ts…)void f2(auto, …); // same as template void f3(T, …)

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
CWG 506C++98passing non-POD class arguments to anellipsis resulted in undefined behaviorpassing such arguments isconditionally-supported withimplementation-defined semantics
CWG 634C++98conditionally-supported class typesmade some SFINAE idioms not workalways supported if unevaluated
CWG 2247C++11no restriction on passing parameterpack or lambda capture to va_startmade ill-formed,no diagnostic required
CWG 2347C++11it was unclear whether scoped enumerations passed toan ellipsis are subject to default argument promotionspassing scoped enumerationsis conditionally-supported withimplementation-defined semantics

# See also