C++ Logo

std-proposals

Advanced search

[std-proposals] Default arguments should participate in template argument deduction

From: Kilian Henneberger <kilis-mail_at_[hidden]>
Date: Mon, 28 Mar 2022 21:07:20 +0200
Hello,

I am wondering whether default arguments should participate in template
argument deduction.
Currently they don't. Therefore, given following function templates:

template<class Pred>
void sort(Pred p = std::less{});

void set_callback(auto cb = []{});

auto create_logger(auto sl = std::source_location::current());

Calling any of those without providing function arguments, will fail to
compile.
Yes, there are solutions to make this work already today without any
changes to the standard.
Therefore the only motivation that I can give is, that this would make
programming more convenient.
In particular, together with abbreviated function templates.

I would very much welcome your feedback!
Thanks and kind regards,
Kilian

Received on 2022-03-28 19:07:23