C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Parameters with default values at arbitrary positions, with empty arguments

From: Bo Persson <bo_at_[hidden]>
Date: Thu, 26 Nov 2026 15:28:21 +0100
On 2026-11-26 at 12:47, Alejandro Colomar via Std-Proposals wrote:
>
> The proposal for C++ would then be so that one can write code like this:
>
> int foo(int a = 42, int b);
>
> And call it as
>
> foo(, 7); // Evaluates as foo(42,7)
>
> This would replace some cases which are currently handled with
> overloads, which are a much heavier machinery (and also more difficult
> to diagnose).
>
>
How is an overload "much heavier"?

To me

int foo(int b) { return foo(42, b); }

seems like a perfectly good solution.

Received on 2026-11-26 14:28:33