C++26: The Oxford Variadic Comma
5 days ago
- #C++26
- #programming
- #language-features
- C++26 deprecates ellipsis parameters without a preceding comma (P3176R1 proposal).
- This change improves C compatibility, reduces confusion with template parameter packs, and preserves design space for future features.
- Currently, C++ allows both `void foo(int, ...)` (C-compatible) and `void foo(int...)` (C++-only), but the latter is being deprecated.
- The comma-less form has caused confusion, especially with template parameter packs and abbreviated function templates.
- The deprecation affects syntax like `void f(int...)` and `void g(auto args...)`, recommending `void f(int, ...)` instead.
- Standalone ellipsis parameters (`void f(...)`) remain valid.
- The change is a deprecation, not removal, allowing for automated fixes.
- This clears the way for future proposals like homogeneous variadic function parameters.