[chromium-dev] C++11 Library Feature Update 2

93 views
Skip to first unread message

Nico Weber

unread,
Dec 9, 2015, 2:03:21 PM12/9/15
to Chromium-dev
Hi,

here's a list of library features that were allowed in the last three weeks (http://chromium-cpp.appspot.com/#library-whitelist)

1. The big new thing is that rvalue references are allowed. Note that the style guide only allows these for move constructors and move assignment operators (and perfect forwarding, but std::forward() isn't allowed yet). You should only rarely feel the need to make a type movable. Most classes should not be copyable, even if movable. Continue to use DISALLOW_COPY_AND_ASSIGN.

https://www.chromium.org/rvalue-references does a great job explaining rvalue references, with pointers to the style guide and to common pitfalls. Give it a read if you haven't.

If your movable type should work with callbacks, you'll need to use DISALLOW_COPY_AND_ASSIGN_WITH_MOVE_FOR_BIND for now. 

There are also a few known bugs in MSVC with respect to rvalue references, see the "Rvalue References" entry on http://chromium-cpp.appspot.com

2. You can now use new-in-C++11 functions in <cmath>

3. You can now use vector::data() This does the same as &*vector::begin(), except it has defined behavior for empty vectors too. 

4. Array tools: You can use global std::begin() / std::end() (they're like container.begin()/end(), but they work for C-style arrays too). Speaking of arrays, you can use std::array<> now too. Neither should be needed frequently.

5. Move tools: You can now use std::make_move_iterator() and the three-argument version of std::move(). Both of these are probably only rarely needed.

Also, alignas() and alignof() are banned for now, since they don't work right in MSVC2013.


As always, the current state of the world is available at http://chromium-cpp.appspot.com

Nico
Reply all
Reply to author
Forward
0 new messages