Hacker News new | ask | show | jobs
by mratzloff 3114 days ago
It's not as major of an update as previous releases, but there are a lot of little convenience features.

String views, same-line nested namespaces, [[fallthrough]], if with init (I'm sure Google single-handedly got this included; it's very Go-reminiscent and really nice when not using exceptions), structured bindings, maybes with std::optional (occasionally useful), and even just something as simple as emplace returning a reference.

What fixes do you think std::move needs, out of curiosity?

2 comments

Its not std::move, but the complexity coming with it. Its a hassle applying move semantics correctly and there is not the one goto solution for simple things. Im not aware of a proposal to change that issue, but at least there should be better defaults.

This talk explains the pain quite well: https://www.youtube.com/watch?v=PNRju6_yn3o

The amount of prayer I have put into RVO and moves happening "right"... As someone who isn't a C++ programmer, is there anything better than looking at annotated asm? Templating everything and trying it with something that isn't copyable? (Actually, would that even work with RVO?)
> As someone who isn't a C++ programmer, is there anything better than looking at annotated asm

put a debug breakpoint in the move constructor and run your tests :p

std::move should extend the lifetime of a temporary like static_cast does. (Or else not accept temporaries). Otherwise, no new features necessary. But that one bites sometimes.