Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 151753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:30:05+00:00 2026-05-11T09:30:05+00:00

I’ve been talking with friends and some completely agree that templates in C++ should

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:30:06+00:00Added an answer on May 11, 2026 at 9:30 am

    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:

    • reducing the repetition of code (generic containers, algorithms)
    • reducing the repetition of code advanced (MPL and Fusion)
    • static polymorphism (=performance) and other compile time calculations
    • policy based design (flexibility, reusability, easier changes, etc)
    • increasing safety at no cost (i.e. dimension analysis via Boost Units, static assertions, concept checks)
    • functional programming (Phoenix), lazy evaluation, expression templates (we can create Domain-specific embedded languages in C++, we have great Proto library, we have Blitz++)
    • other less spectacular tools and tricks used in everyday life:
      • STL and the algorithms (what’s the difference between for and for_each)
      • bind, lambda (or Phoenix) ( write clearer code, simplify things)
      • Boost Function (makes writing callbacks easier)
      • tuples (how to genericly hash a tuple? Use Fusion for example…)
      • TBB (parallel_for and other STL like algorithms and containers)
    • Can you imagine C++ without templates? Yes I can, in the early times you couldn’t use them because of compiler limitations.
    • Would you write in C++ without templates? No, as I would lose many of the advantages mentioned above.

    Downsides:

    • Compilation time (for example throw in Sprit, Phoenix, MPL and some Fusion and you can go for a coffee)
    • People who can use and understand templates are not that common (and these people are useful)
    • People who think that they can use and understand templates are quite common (and these people are dangerous, as they can make a hell out of your code. However most of them after some education/mentoring will join the group mentioned in the previous point)
    • template export support (lack of)
    • error messages could be less cryptic (after some learning you can find what you need, but still…)

    I highly recommend the following books:

    • C++ Templates: The Complete Guide by David Vandevoorde and Nicolai Josuttis (thorough introduction to the subject of templates)
    • Modern C++ Design. Generic Programming and Design Patterns Applied by Andrei Alexandrescu (what is the less known way of using templates to simplify your code, make development easier and result in code robust to changes)
    • C++ Template Metaprogramming by David Abrahms and Aleksey Gutov (again – different way of using the templates)
    • More C++ Idioms from Wikibooks presents some nice ideas.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 72k
  • Answers 72k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer mysqldump -u <user> -p <database> > out.sql It should prompt… May 11, 2026 at 1:46 pm
  • added an answer You might want to check the BackgroundWorker class, it will… May 11, 2026 at 1:46 pm
  • added an answer In case of no images you can just load a… May 11, 2026 at 1:46 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.