C++ Logo

std-discussion

Advanced search

enabling default keyword for default method and function values

From: Vishal Oza <vickoza_at_[hidden]>
Date: Mon, 11 Nov 2019 10:00:09 -0600
I just wanted to know if the following idea is a bad idea. Should we enable
using the default keyword to function input value parameter if we only care
about one parameter that have default parameters both before and after the
parameter we care about?
For example:

int foo(int bar = 3, int baz = 7, int* foobar = nullptr, int* foobaz =
nullptr) { ... }
...

int foobazval = 78;
auto fooval = foo(13, default, default, &foobazval); // = foo(13, 7,
nullptr, &foobazval)


The exceptions are references where there should never be a default value
and possibly type with no default this is only a possibly because the type
could be the same value as the type if the type was default constructed.

Received on 2019-11-11 10:02:44