Possible Duplicate:
What are the disadvantages of using templates?
Reading about templates I found out that for example if you not use a function from a class template, it will not generate code for that(a positive thing). I also saw that you can use compile time porgramming using templates and implement, let's say a factorial example and the result will be know at compile time.
So my question is: what are the negative aspects of using templates ?
Thank you.
A disadvantage: template errors are only detected by the compiler when the template is instantiated. Sometimes, errors in the methods of templates are only detected when the member method is instantiated, regardless if the rest of the template is instantiated.
There are three primary drawbacks to the use of templates. First, many compilers historically have very poor support for templates, so the use of templates can make code somewhat less portable. Second, almost all compilers produce confusing, unhelpful error messages when errors are detected in template code.
Templates simplify the creation of documents. Templates can ease our workload and make us feel less stressed, and, at the same time, they increase efficiency. Templates increase the attention of the audience. They help in saving time and money.
Answer – A template is a sample document that has some pre defined format which contain image or text that may be changed and used by the user easily. It helps you save money and time. Templates promote client satisfaction and clarity. It boosts productivity.
Compile time. Complex, especially recursive templates can take ages to compile.
Error messages. Template error messages are terrifying and generally not very helpful. Concepts would've been great, but sadly the language committee has dropped them from the upcoming standard.
Readability. Templates code can be challenging to read.
Difficulty Much of the underlying tricks rely on not-so-well-known aspects of the language standard, so one needs a decent knowledge of the language to get along with them.
In order for clients to use templates you developed, you have to deliver the source code. This is probably the most significant downside I have encountered in practice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With