Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What about putting common template parameters into an external template in a binary libray?


Na, we will just remove this template nonsense.


I guess preprocessor macros are much better alternative. /s


Probably yes. Macros are about equally bad than templates in my experience (although C++ people will disagree, I do not see much difference). But mostly I plan to just let the compiler specialize the functions during optimization. I haven't looked at this specific problem though.


For one, templates can be stepped through on the debugger without additional effort, offer type checking, don't execute parameters multiple times, and don't require additional parenthesis and curly braces to protect their misuse.


Debuggers can expand macros, and you can also look at the pre-processed output or even compile that (you can't the expanded form with templates). But I agree that if it becomes more complicated this is not very good. But you know, this does not matter too much to me as I will neither use complicated macros nor templates. And simple macros are just fine.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: