hidden passing of __FILE__ and __LINE__ into function

Dmitry via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Apr 17 06:45:18 PDT 2017


On Monday, 17 April 2017 at 10:55:30 UTC, Jonathan M Davis wrote:
> They works, but it results in a new template being instantiated 
> for every call, so you really shouldn't use __FILE__ or 
> __LINE__ as template arguments if you can avoid it.
Does it matter if I anyway use template (S...) ?
And what problem with that new templates for every call? 
Increases .exe size? Needs more memory (runtime? compile-time?)? 
Something else?

> Usually, the better way to handle it is to use runtime 
> arguments, e.g.
> void error(string msg, string file = __FILE__, size_t line = 
> __LINE__)
Is possible use this with (S...)? In some cases I use many 
arguments (5-10, mixed strings and numbers) and I tried to avoid 
the concatenation them into string.

What will be better? Concatenation or templates? Or maybe an 
another way?


More information about the Digitalmars-d-learn mailing list