Chromium Code Reviews| Index: webrtc/base/optional.h |
| diff --git a/webrtc/base/optional.h b/webrtc/base/optional.h |
| index 1bcfd1a8c2fbd00e2a470c1140cc8d57a8b276f4..728ed9e7378c07ce4b2c0c89edecfc497c14c4f7 100644 |
| --- a/webrtc/base/optional.h |
| +++ b/webrtc/base/optional.h |
| @@ -193,6 +193,16 @@ class Optional final { |
| PoisonValue(); |
| } |
| + template <class... Args> |
| + void emplace(Args&&... args) { |
| + if (has_value_) |
| + value_.~T(); |
| + else |
| + UnpoisonValue(); |
| + new (&value_) T(std::forward<Args>(args)...); |
| + has_value_ = true; |
| + } |
|
kwiberg-webrtc
2016/10/18 08:46:19
Yes, it sounds right to destroy + create new rathe
|
| + |
| // Conversion to bool to test if we have a value. |
| explicit operator bool() const { return has_value_; } |