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). Review-Url: https://codereview.chromium.org/2080003002 Cr-Commit-Position: refs/heads/master@{#412199}
This commit is contained in:
@ -76,7 +76,7 @@ Finally, `base::Optional<T>` is integrated with `std::hash`, using
|
||||
|
||||
## How is it implemented?
|
||||
|
||||
`base::Optional<T>` is implemented using `base::AlignedMemory`. The object
|
||||
`base::Optional<T>` is implemented with a union with a `T` member. The object
|
||||
doesn't behave like a pointer and doesn't do dynamic memory allocation. In
|
||||
other words, it is guaranteed to have an object allocated when it is not empty.
|
||||
|
||||
|
Reference in New Issue
Block a user