Template whens and when nots

May 13, 2012 at 11:30am
C++ provides template mechanism

but I am confusing about when we should use template and when we should not.

anybody willing to give me tips or some useful reference?
May 13, 2012 at 1:41pm
use templates hwen you need anything "generic", mostly it's generic types, when you need to have a class that can operate with variable types, not just limited to one type. The only advantage of non-type template parameters isjust in functions, and it's (possible) automatic deduction. Otherwise you can just add them as parameters.
May 13, 2012 at 4:30pm
If you find you need the same code for different data types you should be using a template.
May 13, 2012 at 11:20pm
The only advantage of non-type template parameters isjust in functions, and it's (possible) automatic deduction
I don't understand you ¿could you provide an example? (for both cases)
Topic archived. No new replies allowed.