C++ Logo

std-proposals

Advanced search

[std-proposals] Direct-list-initialization syntax for default function arguments

From: Radu Ungureanu <radu.ungureanu_at_[hidden]>
Date: Tue, 16 Jun 2026 01:43:50 +0300
Hi all,

I want to propose allowing direct-list-initialization syntax for default
function arguments.

Currently, if a type X has an explicit constructor:

 struct X {
     explicit X(int) {}
 };

a default argument can be specified like this:

 void f(X x = X{5}) {}

My proposal would allow the following:

 void f(X x{5}) {}

With semantics equivalent to:

 void f(X x = X{5}) {}

While I am aware this does not add new expressive power, the motivation
is to use direct-list-initialization style syntax for default arguments
without requiring the repetition of the parameter type.

I'd appreciate some feedback on the usefulness of such a feature and any
issues with the proposed semantics or syntax.

Thanks,
Radu Ungureanu

Received on 2026-06-15 22:43:53