News for hackers. Stuff that matters.
Re:C++ Frequently Questioned Answers (2009) by praptak on Tuesday January 25, 2022 @04:34AM (#30069991)
It is possible with every kind of de-duplicating copy-pasted code. You need some boilerplate for the common template (not necessarily in the C++ sense), then some more boilerplate for its instantiations to replace the previously-copypasted blocks of code.

Then the blocks weren't exactly identical, so the template (again, not necessarily C++) needs to gain placeholders/ifs and the instantiations need to fill them/provide conditions.

If you do it with C++ templates using the traits machinery, it generates quite a lot of bloat. It is not a reason to never use these mechanisms, just to be wary of the costs.

Re:C++ Frequently Questioned Answers (2009) by protomolecule on Tuesday January 25, 2022 @05:03PM (#30078758)
"If you do it with C++ templates using the traits machinery, it generates quite a lot of bloat. "

That's exactly the part that I don't understand. How does using traits machinery generate more bloat than some other way to de-duplicate the same code? And what kind of bloat do you have in mind -- source code or binary?