On Saturday, 3 March 2012 at 02:19:55 UTC, Andrej Mitrovic wrote:
Right, but what about template bloat?
You don't have to use templates at all. The __FILE__
and __LINE__ default params work in regular functions.
// not a template, just regular parameters
void awesome(string file = __FILE__, int line = __LINE__) {
printf("called from %s:%d", file, line);
}
They are passed as runtime parameters at the call site:
push dword ptr _TMP1@SYM32[09h] ; the file is pushed here
push dword ptr _TMP1@SYM32[0Bh]
mov EAX,8 ; and the __LINE__ is here
; now it calls the function, note that it is the same
; call all three times
call _D5test97awesomeFAyaiZv@PC32
push dword ptr _TMP1@SYM32[01Fh]
push dword ptr _TMP1@SYM32[021h]
mov EAX,9
call _D5test97awesomeFAyaiZv@PC32
push dword ptr _TMP1@SYM32[035h]
push dword ptr _TMP1@SYM32[037h]
mov EAX,0Ah
call _D5test97awesomeFAyaiZv@PC32
No template bloat if you don't use a template!