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

Side by Side Diff: webrtc/base/optional.h

Issue 1937693002: Replace scoped_ptr with unique_ptr everywhere (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@unique5
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/audio_send_stream.h ('k') | webrtc/base/scoped_ptr.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_BASE_OPTIONAL_H_ 11 #ifndef WEBRTC_BASE_OPTIONAL_H_
12 #define WEBRTC_BASE_OPTIONAL_H_ 12 #define WEBRTC_BASE_OPTIONAL_H_
13 13
14 #include <algorithm> 14 #include <algorithm>
15 #include <memory>
15 #include <utility> 16 #include <utility>
16 17
17 #include "webrtc/base/checks.h" 18 #include "webrtc/base/checks.h"
18 19
19 namespace rtc { 20 namespace rtc {
20 21
21 // Simple std::experimental::optional-wannabe. It either contains a T or not. 22 // Simple std::experimental::optional-wannabe. It either contains a T or not.
22 // In order to keep the implementation simple and portable, this implementation 23 // In order to keep the implementation simple and portable, this implementation
23 // actually contains a (default-constructed) T even when it supposedly doesn't 24 // actually contains a (default-constructed) T even when it supposedly doesn't
24 // contain a value; use e.g. rtc::scoped_ptr<T> instead if that's too 25 // contain a value; use e.g. std::unique_ptr<T> instead if that's too
25 // expensive. 26 // expensive.
26 // 27 //
27 // A moved-from Optional<T> may only be destroyed, and assigned to if T allows 28 // A moved-from Optional<T> may only be destroyed, and assigned to if T allows
28 // being assigned to after having been moved from. Specifically, you may not 29 // being assigned to after having been moved from. Specifically, you may not
29 // assume that it just doesn't contain a value anymore. 30 // assume that it just doesn't contain a value anymore.
30 // 31 //
31 // Examples of good places to use Optional: 32 // Examples of good places to use Optional:
32 // 33 //
33 // - As a class or struct member, when the member doesn't always have a value: 34 // - As a class or struct member, when the member doesn't always have a value:
34 // struct Prisoner { 35 // struct Prisoner {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 private: 124 private:
124 // Invariant: Unless *this has been moved from, value_ is default-initialized 125 // Invariant: Unless *this has been moved from, value_ is default-initialized
125 // (or copied or moved from a default-initialized T) if !has_value_. 126 // (or copied or moved from a default-initialized T) if !has_value_.
126 T value_; 127 T value_;
127 bool has_value_; 128 bool has_value_;
128 }; 129 };
129 130
130 } // namespace rtc 131 } // namespace rtc
131 132
132 #endif // WEBRTC_BASE_OPTIONAL_H_ 133 #endif // WEBRTC_BASE_OPTIONAL_H_
OLDNEW
« no previous file with comments | « webrtc/audio_send_stream.h ('k') | webrtc/base/scoped_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698