C++ Logo


Advanced search

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

From: Zhihao Yuan <zy_at_[hidden]>
Date: Tue, 29 Mar 2022 18:37:22 +0000
On Tuesday, March 29th, 2022 at 9:42 AM, Edward Catmur via Std-Proposals <std-proposals_at_[hidden]> wrote:

> On Tue, 29 Mar 2022 at 16:38, Tom Honermann via Std-Proposals <std-proposals_at_[hidden]> wrote:

> > > void start_device(auto process_callback, auto started_callback = []{}, auto stopped_callback = []{});
> >

> > Do you really want templates in that case? It seems to me that std::function_ref as proposed in P0792 / P2472 provides a better solution here.

> std::function_ref is a great solution in many cases, but it does mean paying the overhead of type erasure, so you may prefer to keep it a template and use `std::invocable<> auto`.

Are you sure about that: https://godbolt.org/z/PMT3GG56G

--Zhihao Yuan, ID lichray

The best way to predict the future is to invent it.


Received on 2022-03-29 18:37:27