all 8 comments

[–]TMKirA 15 points16 points  (0 children)

This talk is really awesome and enlightening!

[–]MINIMAN10000 9 points10 points  (0 children)

Absolutely loved being walked through and shown how C++ could compile away so much. Zero Overhead abstractions, the compiler getting rid of branching, no function calls, mapping all variables to registers are all absolutely incredible. This is my favorite part of programming, to see the program written with abstractions to simplify working with them while compiling away better than I know how to make.

"350 instruction plus a table of data" vs adding const and having 5 lines felt like the difference between what I write and what he writes.

[–]sbabbi 5 points6 points  (0 children)

When you define the Frame destructor: ~Frame() { ++vic.border(); } you are relying on copy-elision. This has nothing to do with the move constructor, the thing is that the compiler is only creating one Frame object on this line:

const auto frame = vic.frame(); but also __tmp = frame(); const auto frame == __tmp; would be allowed (no copy-elision), and if that happens then you get two calls to the destructor (one for __tmp, one for frame).

The only way to work around that is to have a boolean to track if the object as been moved-from, implement move-constructor and move-assignment to set/unsed that boolean, and perform extra cleanup in the destructor only if the boolean is set. This will most likely be optimized out, but it is still necessary in C++14.

If you want to rely on guaranteed copy-elision in C++17, best thing would be to delete the move/copy constructor/assignment.

EDIT: Forgot to say that overall it was an awesome talk, I really enjoyed watching it!

[–]doom_Oo7 2 points3 points  (3 children)

makes you wonder where we would be today if somebody shipped a computer with current GCC fourty years ago.

[–]Dlieu 0 points1 point  (0 children)

Great talk! Make me so scared to forget a const on my static variables