Re:A brief introduction to C++'s model for type- and resourc...
by hellofunk on Friday January 15, 2016 @01:31PM
(#10911109)
Well, if you are going to choose just one feature to reach for in C++, template metaprogramming is probably not going to be it. Even a lot of devs who are very comfortable with other C++ tools and idioms don't write, if any, template code. I wouldn't think that someone would avoid all the other C++ features, but then willingly go down the road of writing templates.
The features are dependent on each other though. The flipside of my example elsewhere in the thread: if you want to use templates to eliminate repeated code, you more-or-less need to make any classes you want to template over use RAII (or else do very error-prone partial template specialization to ensure your things are initialized and deininitialized correctly). So then you have to use exceptions, because if you're doing complex logic in your constructors then you need a way to report failure. So then you have to make your code exception-safe, which means making everything else RAII.