C++11 Library Feature Update

88 views
Skip to first unread message

Dana Jansens

unread,
Nov 18, 2015, 6:59:32 PM11/18/15
to chromium-dev
Hey,

After an exciting first week of C++11 library support, here's an update on what is now allowed to be used in chromium code: http://chromium-cpp.appspot.com/#library-whitelist

Please see https://groups.google.com/a/chromium.org/forum/#!forum/cxx for previous and ongoing discussions (a few of them have bled out to chromium-dev as well, of course).

1. Containers containing movable types: std::vector<scoped_ptr>
- This allows getting rid of ScopedVector. A lot of people have been contributing to this from all over the codebase already! Feel free to join in the fun.

2. Lexicographical struct comparison: std::tie(a, b, c) < std::tie(rhs.a, rhs.b, rhs.c)
- This can be used to implement comparison operators rather than writing a series of if a == rhs.a then.. else..
- General use of std::tuple or std::tie has not been allowed outside of this use case.

3. Move Semantics: std::move()
- std::move() can be used in place of .Pass() for scoped_ptr, scoped_refptr, ScopedGeneric, and a few other move-only types already in our codebase.
- std::move() can be used with any standard library types which were previously allowed.
- Please read https://sites.google.com/a/chromium.org/dev/rvalue-references to learn what move() does before you use it. (Hint: it doesn't move anything.)
- Writing your own move constructors is not yet allowed without approval from styleguide/c++11 OWNERS.

4. Conditional Type Selection: std::enable_if and std::conditional
- These may be used where we do other tricks right now in templated code such as the implementation of base::Callback. We don't expect people to actually use these commonly (or at all).

5. Type Traits: Class templates within <type_traits>
- These can replace some custom implementations of type traits in base/, but not all type traits are available on all platforms yet (eg std::underlying_type doesn't work in supported linux platforms).
Happy hacking,
Dana

Jeremy Roman

unread,
Nov 18, 2015, 7:06:14 PM11/18/15
to Dana Jansens, chromium-dev
On Wed, Nov 18, 2015 at 6:57 PM, 'Dana Jansens' via Chromium-dev <chromi...@chromium.org> wrote:
Hey,

After an exciting first week of C++11 library support, here's an update on what is now allowed to be used in chromium code: http://chromium-cpp.appspot.com/#library-whitelist

Please see https://groups.google.com/a/chromium.org/forum/#!forum/cxx for previous and ongoing discussions (a few of them have bled out to chromium-dev as well, of course).

1. Containers containing movable types: std::vector<scoped_ptr>
- This allows getting rid of ScopedVector. A lot of people have been contributing to this from all over the codebase already! Feel free to join in the fun.

2. Lexicographical struct comparison: std::tie(a, b, c) < std::tie(rhs.a, rhs.b, rhs.c)
- This can be used to implement comparison operators rather than writing a series of if a == rhs.a then.. else..
- General use of std::tuple or std::tie has not been allowed outside of this use case.

3. Move Semantics: std::move()
- std::move() can be used in place of .Pass() for scoped_ptr, scoped_refptr, ScopedGeneric, and a few other move-only types already in our codebase.

scoped_refptr isn't move-only. Can std::move be used for any movable type, or only move-only?
 
- std::move() can be used with any standard library types which were previously allowed.
- Please read https://sites.google.com/a/chromium.org/dev/rvalue-references to learn what move() does before you use it. (Hint: it doesn't move anything.)
- Writing your own move constructors is not yet allowed without approval from styleguide/c++11 OWNERS.

4. Conditional Type Selection: std::enable_if and std::conditional
- These may be used where we do other tricks right now in templated code such as the implementation of base::Callback. We don't expect people to actually use these commonly (or at all).

5. Type Traits: Class templates within <type_traits>
- These can replace some custom implementations of type traits in base/, but not all type traits are available on all platforms yet (eg std::underlying_type doesn't work in supported linux platforms).
Happy hacking,
Dana

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

Dana Jansens

unread,
Nov 18, 2015, 7:09:07 PM11/18/15
to Jeremy Roman, chromium-dev
On Wed, Nov 18, 2015 at 4:05 PM, Jeremy Roman <jbr...@chromium.org> wrote:
On Wed, Nov 18, 2015 at 6:57 PM, 'Dana Jansens' via Chromium-dev <chromi...@chromium.org> wrote:
Hey,

After an exciting first week of C++11 library support, here's an update on what is now allowed to be used in chromium code: http://chromium-cpp.appspot.com/#library-whitelist

Please see https://groups.google.com/a/chromium.org/forum/#!forum/cxx for previous and ongoing discussions (a few of them have bled out to chromium-dev as well, of course).

1. Containers containing movable types: std::vector<scoped_ptr>
- This allows getting rid of ScopedVector. A lot of people have been contributing to this from all over the codebase already! Feel free to join in the fun.

2. Lexicographical struct comparison: std::tie(a, b, c) < std::tie(rhs.a, rhs.b, rhs.c)
- This can be used to implement comparison operators rather than writing a series of if a == rhs.a then.. else..
- General use of std::tuple or std::tie has not been allowed outside of this use case.

3. Move Semantics: std::move()
- std::move() can be used in place of .Pass() for scoped_ptr, scoped_refptr, ScopedGeneric, and a few other move-only types already in our codebase.

scoped_refptr isn't move-only. Can std::move be used for any movable type, or only move-only?

There's no rules around where you can/can't use move(), so ya with any movable type. And scoped_refptr does have a move constructor (and a Pass() function to support that before move() was allowed).

Gabriel Charette

unread,
Nov 19, 2015, 9:48:55 AM11/19/15
to dan...@google.com, chromium-dev
On Wed, Nov 18, 2015 at 6:58 PM 'Dana Jansens' via Chromium-dev <chromi...@chromium.org> wrote:
Hey,

After an exciting first week of C++11 library support, here's an update on what is now allowed to be used in chromium code: http://chromium-cpp.appspot.com/#library-whitelist

Please see https://groups.google.com/a/chromium.org/forum/#!forum/cxx for previous and ongoing discussions (a few of them have bled out to chromium-dev as well, of course).

1. Containers containing movable types: std::vector<scoped_ptr>
- This allows getting rid of ScopedVector. A lot of people have been contributing to this from all over the codebase already! Feel free to join in the fun.

2. Lexicographical struct comparison: std::tie(a, b, c) < std::tie(rhs.a, rhs.b, rhs.c)
- This can be used to implement comparison operators rather than writing a series of if a == rhs.a then.. else..
- General use of std::tuple or std::tie has not been allowed outside of this use case.

3. Move Semantics: std::move()
- std::move() can be used in place of .Pass() for scoped_ptr, scoped_refptr, ScopedGeneric, and a few other move-only types already in our codebase.

"can" be used? Is there a preference or will the codebase become a random mix of both?
 
- std::move() can be used with any standard library types which were previously allowed.
- Please read https://sites.google.com/a/chromium.org/dev/rvalue-references to learn what move() does before you use it. (Hint: it doesn't move anything.)
- Writing your own move constructors is not yet allowed without approval from styleguide/c++11 OWNERS.

4. Conditional Type Selection: std::enable_if and std::conditional
- These may be used where we do other tricks right now in templated code such as the implementation of base::Callback. We don't expect people to actually use these commonly (or at all).

5. Type Traits: Class templates within <type_traits>
- These can replace some custom implementations of type traits in base/, but not all type traits are available on all platforms yet (eg std::underlying_type doesn't work in supported linux platforms).
Happy hacking,
Dana

--

Daniel Cheng

unread,
Nov 19, 2015, 1:09:35 PM11/19/15
to g...@chromium.org, dan...@google.com, chromium-dev
On Thu, Nov 19, 2015 at 6:48 AM Gabriel Charette <g...@chromium.org> wrote:
On Wed, Nov 18, 2015 at 6:58 PM 'Dana Jansens' via Chromium-dev <chromi...@chromium.org> wrote:
Hey,

After an exciting first week of C++11 library support, here's an update on what is now allowed to be used in chromium code: http://chromium-cpp.appspot.com/#library-whitelist

Please see https://groups.google.com/a/chromium.org/forum/#!forum/cxx for previous and ongoing discussions (a few of them have bled out to chromium-dev as well, of course).

1. Containers containing movable types: std::vector<scoped_ptr>
- This allows getting rid of ScopedVector. A lot of people have been contributing to this from all over the codebase already! Feel free to join in the fun.

2. Lexicographical struct comparison: std::tie(a, b, c) < std::tie(rhs.a, rhs.b, rhs.c)
- This can be used to implement comparison operators rather than writing a series of if a == rhs.a then.. else..
- General use of std::tuple or std::tie has not been allowed outside of this use case.

3. Move Semantics: std::move()
- std::move() can be used in place of .Pass() for scoped_ptr, scoped_refptr, ScopedGeneric, and a few other move-only types already in our codebase.

"can" be used? Is there a preference or will the codebase become a random mix of both?

I believe the preference in new code should be towards using std::move(). At some point, we'll do a bulk conversion of the remaining calls to Pass() and remove the helper macros altogether.

Daniel
Reply all
Reply to author
Forward
0 new messages