Date: Sun, 22 Mar 2026 13:14:21 +0300
On March 22, 2026 12:17:22 PM Bo Persson via Std-Proposals
<std-proposals_at_[hidden]> wrote:
> On 2026-03-22 at 09:25, Ivan Lazaric via Std-Proposals wrote:
>> Would it be possible/make sense/be better to default the template
>> parameter to decltype of expression when possible?
>>
>> void func(auto arg = 0) { }
>>
>> // equivalent to:
>>
>> template<typename Arg = decltype(0)>
>> void func(Arg arg = 0) { }
>
> It would be less typing to just add an overload:
>
> void func() { func(0); }
I think, the argument was that the auto parameter variant of the code would
automatically work as the explicit template variant. Adding an additional
function overload is neither shorter nor equivalent to that one auto
parameter function.
<std-proposals_at_[hidden]> wrote:
> On 2026-03-22 at 09:25, Ivan Lazaric via Std-Proposals wrote:
>> Would it be possible/make sense/be better to default the template
>> parameter to decltype of expression when possible?
>>
>> void func(auto arg = 0) { }
>>
>> // equivalent to:
>>
>> template<typename Arg = decltype(0)>
>> void func(Arg arg = 0) { }
>
> It would be less typing to just add an overload:
>
> void func() { func(0); }
I think, the argument was that the auto parameter variant of the code would
automatically work as the explicit template variant. Adding an additional
function overload is neither shorter nor equivalent to that one auto
parameter function.
Received on 2026-03-22 10:14:25
