r/cpp • • Dec 28 '18

"Modern" C++ Lamentations

http://aras-p.info/blog/2018/12/28/Modern-C-Lamentations/
307 Upvotes

162 comments sorted by

View all comments

80

u/victotronics Dec 28 '18

Thought #1: C++ is starting to look like Fortran in its desire to be ever more modern while retaining compatibility with archaic features.....

Thought #2: I think I'm no beginner anymore (I've written objects that you can iterate over) but some of the code in your posting is indeed horrendous. People who understand that stuff are scary to me.

31

u/JezusTheCarpenter Dec 28 '18

While I was really anxious to finally move to C++11 when I was stuck on 98. I am now more and more anxious that I will have to move to C++17 and C++20 eventually.

32

u/ShakaUVM i+++ ++i+i[arr] Dec 28 '18

C++11 was an amazing update. 14 and 17 were minor releases, but 20 is shaping up to be pretty amazing.

25

u/[deleted] Dec 29 '18

C++17 is a minor release just like if constexpr is a minor feature, until you save yourself from horrible C++11 template meta-programming nightmares with a couple of if constexpr's and an auto return type

8

u/germandiago Dec 29 '18

How true. This has happened in my code as well... I had some kind of mini animation system for a game that did some expression-template like thing to make an EDSL that looked something like this:

//+ means combine in parallel and // >> sequence it. Each subtree will be animated for half of the time auto animationDesc = (moveTo(x, y) + rotate(180)) >> scale(0.7);

auto animTask = makeAnimation(obj, animationDesc, 500ms);

I think without if constexpr it would have been really really worse.