I've been talking with friends and some completely agree that templates in C++ should be used, others disagree entirely.
Some of the good things are:
- They are more safe to use (type safety).
- They are a good way of doing generalizations for APIs.
What other good things can you tell me about C++ templates?
What bad things can you tell me about C++ templates?
Edit: One of the reasons I'm asking this is that I am studying for an exam and at the moment I am covering the topic of C++ templates. So I am trying to understand a bit more on them.
Best Solution
Templates are a very powerful mechanism which can simplify many things. However to use them properly requires much time and experience - in order to decide when their usage is appropriate.
For me the most important advantages are:
for
andfor_each
)parallel_for
and other STL like algorithms and containers)Downsides:
export
support (lack of)I highly recommend the following books: