News for hackers. Stuff that matters.
Re:C++20 Idioms for Parameter Packs by Night_Thastus on Tuesday February 27, 2024 @01:21PM (#39527513)
Am I the only one who has never needed to do variadic anything? (minus something like flags)

I'm really not sure what type of problem variadics solve that can't be done simpler with something else, like default arguments, std::optional, containers like vector, etc.

Re:C++20 Idioms for Parameter Packs by spacechild1 on Tuesday February 27, 2024 @01:41PM (#39527803)
But you have certainly been using variadic functions or classes, e.g. everytime you call std::make_unique(). Someone needs to write those :)
Re:C++20 Idioms for Parameter Packs by Night_Thastus on Tuesday February 27, 2024 @02:07PM (#39528204)
That's a fair point. It wasn't a criticism of the feature - more confusion about what exactly it's supposed to be good at solving. I'm never clear if I should be reaching for it. make_unique() is a good example.
Re:C++20 Idioms for Parameter Packs by gpderetta on Tuesday February 27, 2024 @02:24PM (#39528465)
Just as a simple example, Optional and containers can use variadics to forward arguments to emplace-construct their contained objects.

If you do not need variadics that's fine, you do not have to force them where they don't belong.

Re:C++20 Idioms for Parameter Packs by logicchains on Tuesday February 27, 2024 @01:58PM (#39528057)
You can't do type-checked multi-dimensional containers like tensors without variadics. You could only manually create Tensor1D, Tensor2D, Tensor3D... types. You also couldn't implement tuple types without them.
Re:C++20 Idioms for Parameter Packs by Georgelemental on Tuesday February 27, 2024 @09:22PM (#39533131)
Variadics are rarely useful, but when you need them (generally in highly generic library code) you really need them. (I don't know C++, but am familiar with the pain of not having variadics in Rust, and the piles of macros required to work around it)