Implicit Constructors
Steven Schveighoffer
schveiguy at yahoo.com
Fri Oct 13 12:43:44 UTC 2017
On 10/13/17 2:33 AM, Jacob Carlborg wrote:
> Hmm, I didn't know that syntax was legal. But apparently it's some form
> of typesafe variadic function [1]. It also work for built-in types:
>
> void foo(int i ...){}
>
> void main()
> {
> foo(3);
> foo(3, 4); // error, too many arguments
> }
>
> Not sure what the purpose of the latter is.
>
> [1] https://dlang.org/spec/function.html#typesafe_variadic_functions
>
I believe it probably calls the builtin constructor:
auto i = int(3);
auto i = int(3, 4); // error
Indeed it seems useless to have such a thing, as most builtin ctors
would be equivalent to passing a convertible value anyway.
-Steve
More information about the Digitalmars-d
mailing list