Date: Mon, 11 Nov 2019 21:19:10 -0600
These would be error condition and how values work. If someone enter
default as a input parameter to a reference type it makes no as references
refer to existing variables. Entering default would first look for default
values in the definition first then a default constructed type in no value
is specified. I would like a shorter keyword but default is clear. This
would be a new language feature and might need linker support.
On Nov 11, 2019 8:50 PM, "Edward Diener via Std-Discussion" <
std-discussion_at_[hidden]> wrote:
On 11/11/2019 11:00 AM, Vishal Oza via Std-Discussion wrote:
> 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.
>
>
I have also often thought that it would be useful, and cost very little, if
the 'default' keyword could be used to specify the default value any time a
function, function template, or class template specified default values for
their parameters. This would eliminate the need for the programmer to have
to manually specify as an argument the correct default value for a
parameter, when the compiler already has that information in the definition
of a construct that allows it to automatically know what that default value
actually is.
I do not understand your discussion above regarding the exceptions to such
a suggested addition to the C++ standard. As long as there is a default
value for a parameter specified, why should I care what type that parameter
is when proposing that the 'default' keyword be used to signify that value
as an argument ?
default as a input parameter to a reference type it makes no as references
refer to existing variables. Entering default would first look for default
values in the definition first then a default constructed type in no value
is specified. I would like a shorter keyword but default is clear. This
would be a new language feature and might need linker support.
On Nov 11, 2019 8:50 PM, "Edward Diener via Std-Discussion" <
std-discussion_at_[hidden]> wrote:
On 11/11/2019 11:00 AM, Vishal Oza via Std-Discussion wrote:
> 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.
>
>
I have also often thought that it would be useful, and cost very little, if
the 'default' keyword could be used to specify the default value any time a
function, function template, or class template specified default values for
their parameters. This would eliminate the need for the programmer to have
to manually specify as an argument the correct default value for a
parameter, when the compiler already has that information in the definition
of a construct that allows it to automatically know what that default value
actually is.
I do not understand your discussion above regarding the exceptions to such
a suggested addition to the C++ standard. As long as there is a default
value for a parameter specified, why should I care what type that parameter
is when proposing that the 'default' keyword be used to signify that value
as an argument ?
-- Std-Discussion mailing list Std-Discussion_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
Received on 2019-11-11 21:21:30