Quantcast
Channel: Tools
Viewing all articles
Browse latest Browse all 91752

Forum Post: RE: Templates - What potential problems are associated with their usage?

$
0
0

So since I am attempting to reduce code bloat I am trying to determine if using a template class with two different template parameters will cause duplication in memory of the function. For instance, I believe if the method uses the template argument heavily then the code will be compiled more than once and memory will be required for each "version" of that function. On the other hand, if the argument is not used in the function but the method is part of a template class will it duplicate the function each time a different template arg is used?

The second question was really asking the following. I have heard that all template functions are inline. Can the compiler choose to not inline these functions but instead even have a symbol in the MAP file for these functions if it chooses? Maybe when the function is very long?

What can I do to avoid bloating the code with template usage. We do use optimization levels higher than 2. The compiler does inline many functions that did not use that keyword. My question is, what does the compiler do to avoid inlining or what should i do to prevent problems.

Thanks

Chris 


Viewing all articles
Browse latest Browse all 91752

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>