Phobos: __FILE__ as template default parameter

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 20 07:28:06 PDT 2016


On 2016-06-19 12:43, Dicebot wrote:

> Yes. It is necessary because runtime parameter list is variadic -
> template bloat in such cases is usually eliminated by forwarding to
> another private method immediately turning file/line into first runtime
> argument instead.

Would it be a bad idea to allow this in the compiler:

void foo(Args...)(Args args, string file = __FILE__, size_t line = 
__LINE__);

It wouldn't be possible to pass "file" or "line" when calling "foo". But 
it's useful for the special default values, __FILE__ and __LINE__.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list