C++ templates may reduce memory footprint

One of the complaints about C++ templates is that they can cause code bloat. But Scott Meyers pointed out in an interview that some people are using templates in embedded systems applications because templates result in smaller code.

C++ compilers only generate code for template methods that are actually used in an application, so it’s possible that code using templates¬†may result in a smaller executable than code that a more traditional object oriented approach.

Leave a Reply

Your email address will not be published. Required fields are marked *