C++ Logo


Advanced search

Re: Flexible function parameters

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Thu, 9 Jul 2020 23:24:35 -0400
On Thu, Jul 9, 2020 at 4:19 PM Matthew Woehlke via Std-Proposals
<std-proposals_at_[hidden]> wrote:
> On 09/07/2020 11.06, Filippo Casarin via Std-Proposals wrote:
> > Given the code
> >
> > void foo(int a=1000696967, int b=1000696969);
> >
> > In c++20 there is no way to call `foo` specifying a value for `b` but not
> > for `a`
> I would much prefer named parameters for that.
> Also, use of `;` inside a parameter list is very nearly 'over my dead
> body' territory, at least for me. And I want `:` for named parameters.
> > 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.

Received on 2020-07-09 22:27:58