Typesafe variadics in any position
Steven Schveighoffer
schveiguy at yahoo.com
Tue Feb 26 12:52:46 PST 2013
On Tue, 26 Feb 2013 15:36:11 -0500, Andrej Mitrovic
<andrej.mitrovich at gmail.com> wrote:
> On Tuesday, 26 February 2013 at 20:29:51 UTC, Steven Schveighoffer wrote:
>> Would it be something people want?
>
> Yes. Also related: http://d.puremagic.com/issues/show_bug.cgi?id=8687
>
> One extremely common and important use-case of allowing it is this:
>
> foo(string[] args..., string file = __FILE__, size_t line = __LINE__);
>
> Right now as soon as you introduce variadics you can forget about using
> __FILE__/__LINE__ at runtime (unless you resort to some inner-template
> tricks, but that only works in some cases methinks, probably not at
> runtime).
Well, except that example wouldn't work :)
This would though:
foo(string[] args..., size_t line = __LINE__, string file = __FILE__);
Excellent use case though!
-Steve
More information about the Digitalmars-d
mailing list