3 ms·
> The problem is you're demanding that the entire coding population of a large company "get the hang of it" or else be confused by their tools. The fact of lif
by kentonv 12y ago
> The problem is you're demanding that the entire coding population of a large company "get the hang of it" or else be confused by their tools.
The fact of life in C++ is that you have to grasp a number of not-entirely-intuitive concepts before you can be effective with it. Rvalue references are not particularly hard compared to many of the others. Consider how much time newbies spend wrapping their head around pointers -- something that experienced C++ programmers have absolutely no trouble with.
The only reason we're holding rvalue references to a higher standard than any other C++ feature is because they're new, which means that even people who have been coding in C++ for decades suddenly find that there is a language construct they don't immediately understand. Not having felt this way for a very long time, they conclude that this particular construct must be much more complicated than everything else, when in fact it's not.
> The overwhelming number of allocation bugs with C++ code are treated very well by RAII already.
Move semantics make it vastly easier to use RAII in the first place. Without them, RAII does not play nicely with transferring ownership over a call or a return. You can use reference-counted smart pointers, but they are slow (require atomic ops). You can try to emulate move semantics via documentation and conventions, but this is error-prone. Clean ownership transfers have always been a sore spot in C++ prior to rvalue references.
I don't know about you, but the introduction of move semantics into my style completely transformed my code for the better.
- aboodman 12y agoChromium uses move semantics all over the place: https://code.google.com/p/chromium/codesearch#search/&q=move_only_type&sq=package:chromium&type=cs https://code.google.com/p/chromium/codesearch#search/&q=move... We don't allow the standard version yet partly for the reason explained downthread: it requires stl support to be very useful and not all the platforms we target are compatible yet.