On 3/29/22 6:55 AM, Timur Doumler via Std-Proposals wrote:
I don’t agree that the second example is bizarre. In fact, I had this exact case in a real-world codebase not too long ago. The idea was that you start an audio device and pass it a process callback (which is mandatory) as well as “device started” and device stopped” callbacks, which are optional callbacks that the device will call before it starts processing and after it stopped processing so you can allocate/deallocate resources required for processing. It would be very nice to be able to write
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.