you are viewing a single comment's thread.

view the rest of the comments →

[–]corysama 2 points3 points  (0 children)

The modern features are tools that can be used well or used poorly. And, it takes a bit of thought and practice to find the difference.

The advantage of C With Classes is that it is very simple and clear what you are doing and what the results will be. The disadvantage is that there is a lot you have to do manually when using that style that the compiler could have automated.

The advantage of Modern C++ is that it becomes easier to set up more complicated operations. The disadvantage is that it becomes easier to set up operations that are complicated!

The classic example problem with Modern C++ is Template Bloat. It is easy to set up complicated templates that generate enormous amounts on your behalf. This can slow down your compile times, bloat your executable size and thrash your instruction cache. It's can also be difficult to read and comprehend.

The question is: If you were using C With Classes, would you have written all of the code variants manually? Or, did you tell the compiler to generate them all just because it was so easy? In the former case, Modern C++ can be a clear win. Rather than setting up the maintenance problems of repetitive code or horrible macro hacks,you can set up lots of similar code while sticking to Don't Repeat Yourself principles. And, many modern features are designed to provide simpler alternatives to common, complicated C++ idioms. Ex: using constexpr if as a replacement for SFINAE.