Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Issue 2080003002: base::Optional: Use anonymous union instead of base::AlignedMemory (Closed)

Created:
4 years, 6 months ago by kwiberg-chromium
Modified:
4 years, 4 months ago
Reviewers:
danakj, PEConn
CC:
mlamouri (slow - plz ping), chromium-reviews, danakj+watch_chromium.org, jbroman+cpp_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

base::Optional: Use anonymous union instead of base::AlignedMemory Because it's simpler, and accomplishes the same thing. Also modify the C++11 allowed features list to allow unions with class members, to make this change style guide compliant. :-) This is adapted from https://codereview.webrtc.org/2071003003/ by ossu@webrtc.org (which adapted the technique from WebRTC's rtc::Optional, where it has been in use since May 9: https://crrev.com/d040480f69cc6fe65dd101c493d0561a0cdbaa4a). Committed: https://crrev.com/882859a7237ac08da724cabfc863e44f9e63f520 Cr-Commit-Position: refs/heads/master@{#412199}

Patch Set 1 #

Total comments: 2

Patch Set 2 : Add an extra member to the union #

Patch Set 3 : add comments #

Patch Set 4 : rebase #

Total comments: 6

Patch Set 5 : review nits #

Unified diffs Side-by-side diffs Delta from patch set Stats (+41 lines, -30 lines) Patch
M base/optional.h View 1 2 3 4 6 chunks +32 lines, -21 lines 0 comments Download
M docs/optional.md View 1 1 chunk +1 line, -1 line 0 comments Download
M styleguide/c++/c++11.html View 1 2 3 2 chunks +8 lines, -8 lines 0 comments Download

Messages

Total messages: 30 (14 generated)
kwiberg-chromium
4 years, 6 months ago (2016-06-18 05:27:13 UTC) #2
danakj
https://codereview.chromium.org/2080003002/diff/1/base/optional.h File base/optional.h (right): https://codereview.chromium.org/2080003002/diff/1/base/optional.h#newcode47 base/optional.h:47: T value_; Why does libcxx put a second field ...
4 years, 6 months ago (2016-06-22 23:00:04 UTC) #3
danakj
Also, can you send an email to cxx@chromium.org about using unions with class members? That ...
4 years, 6 months ago (2016-06-22 23:01:08 UTC) #4
danakj
On 2016/06/22 23:01:08, danakj wrote: > Also, can you send an email to mailto:cxx@chromium.org about ...
4 years, 6 months ago (2016-06-22 23:01:37 UTC) #5
kwiberg-chromium
https://codereview.chromium.org/2080003002/diff/1/base/optional.h File base/optional.h (right): https://codereview.chromium.org/2080003002/diff/1/base/optional.h#newcode47 base/optional.h:47: T value_; On 2016/06/22 23:00:03, danakj wrote: > Why ...
4 years, 6 months ago (2016-06-23 02:18:49 UTC) #6
ossu-chromium
> It seems like it's required to make constexpr construction work fully: > https://akrzemi1.wordpress.com/2012/12/13/constexpr-unions/. (The ...
4 years, 6 months ago (2016-06-23 08:20:06 UTC) #7
ossu-chromium
On 2016/06/23 08:20:06, ossu1 wrote: > Hmm... I like the solution with dummy_t (though obviously, ...
4 years, 6 months ago (2016-06-23 13:44:06 UTC) #8
danakj
On 2016/06/23 13:44:06, ossu1 wrote: > On 2016/06/23 08:20:06, ossu1 wrote: > > Hmm... I ...
4 years, 6 months ago (2016-06-23 18:52:11 UTC) #9
PEConn
You'll need to update docs/optional.md as it contains references to it being implemented with base::AlignedMemory.
4 years, 5 months ago (2016-06-27 08:07:20 UTC) #11
mlamouri (slow - plz ping)
Removing myself from the reviewers list. I'm very happy with danakj@ taking care of this.
4 years, 5 months ago (2016-06-27 12:29:37 UTC) #12
kwiberg-chromium
I think I've tied up all the loose ends now. PTAL.
4 years, 4 months ago (2016-08-15 11:17:49 UTC) #18
danakj
Couple nits LGTM tho https://codereview.chromium.org/2080003002/diff/60001/base/optional.h File base/optional.h (right): https://codereview.chromium.org/2080003002/diff/60001/base/optional.h#newcode47 base/optional.h:47: // empty_ exists so that ...
4 years, 4 months ago (2016-08-15 21:22:58 UTC) #19
kwiberg-chromium
https://codereview.chromium.org/2080003002/diff/60001/base/optional.h File base/optional.h (right): https://codereview.chromium.org/2080003002/diff/60001/base/optional.h#newcode47 base/optional.h:47: // empty_ exists so that the union will always ...
4 years, 4 months ago (2016-08-16 08:23:47 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2080003002/80001
4 years, 4 months ago (2016-08-16 09:38:52 UTC) #27
commit-bot: I haz the power
Committed patchset #5 (id:80001)
4 years, 4 months ago (2016-08-16 09:42:40 UTC) #28
commit-bot: I haz the power
4 years, 4 months ago (2016-08-16 09:44:23 UTC) #30
Message was sent while issue was closed.
Patchset 5 (id:??) landed as
https://crrev.com/882859a7237ac08da724cabfc863e44f9e63f520
Cr-Commit-Position: refs/heads/master@{#412199}

Powered by Google App Engine
This is Rietveld 408576698