On Tuesday, 26 February 2013 at 20:52:46 UTC, Steven
Schveighoffer wrote:
On Tue, 26 Feb 2013 15:36:11 -0500, Andrej Mitrovic
<[email protected]> 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
or use a new struct
struct SourcePos {
string file;
size_t line;
}
foo(string[] args..., SourcePos pos = SourcePos(__FILE__,
__LINE__));