Keyword (C++)

Faking keyword arguments to functions in C++ - blog / HN

The add_argument method takes a single argument which is a struct. The extra curly braces inside the parentheses boil down to “whatever the underlying argument is, construct it in place with these parameters”. The dotted names are designated initializers, so those fields get the specified value whereas other fields get their default values.

parser.add_argument({.name{"size"},.other{true}});
Written on June 20, 2026, Last update on
c++ keyword