C++ Logo

std-proposals

Advanced search

Re: Flexible function parameters

From: Matthew Woehlke <mwoehlke.floss_at_[hidden]>
Date: Mon, 13 Jul 2020 10:20:34 -0400
On 09/07/2020 23.24, Jason McKesson via Std-Proposals wrote:
> On Thu, Jul 9, 2020 at 4:19 PM Matthew Woehlke wrote:
>> On 09/07/2020 11.06, Filippo Casarin via Std-Proposals wrote:
>>> In c++20 you can't have multiple parameters packs in a function
>>
>> Language-level tuples, which have been kicked around, are probably a
>> better solution to that.
>
> Even without language-level tuples per-se, you can accomplish similar
> effects with regular tuples:
>
> template<typename ...Args1, typename ...Args2>
> void func(std::tuple<Args1...> args1, std::tuple<Args2...> args2);
>
> Perfect forwarding doesn't exactly work here, but with generalized
> pack declaration and usage (P1858), using `args1` and `args2` will be
> almost as simple as using a parameter pack itself.

I was assuming (perhaps incorrectly) that would still be obnoxious for
the *caller*. If the *caller* can call that function with no more
overhead than adding some curly braces (i.e. no `make_tuple`), then you
are correct, and thank you for the correction. (Honestly, I'm less
concerned about any gymnastics the *callee* might need to undertake, but
you are also correct of course that P1858 would greatly help. Of course,
even with the OP's proposal, you'd probably want P1858 ;-).)

-- 
Matthew

Received on 2020-07-13 09:23:52