OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 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 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 RTC_DCHECK(!error.ok()); | 217 RTC_DCHECK(!error.ok()); |
218 } | 218 } |
219 | 219 |
220 // Constructs a new RTCErrorOr with the given value. After calling this | 220 // Constructs a new RTCErrorOr with the given value. After calling this |
221 // constructor, calls to value() will succeed, and calls to error() will | 221 // constructor, calls to value() will succeed, and calls to error() will |
222 // return a default-constructed RTCError. | 222 // return a default-constructed RTCError. |
223 // | 223 // |
224 // NOTE: Not explicit - we want to use RTCErrorOr<T> as a return type | 224 // NOTE: Not explicit - we want to use RTCErrorOr<T> as a return type |
225 // so it is convenient and sensible to be able to do 'return T()' | 225 // so it is convenient and sensible to be able to do 'return T()' |
226 // when the return type is RTCErrorOr<T>. | 226 // when the return type is RTCErrorOr<T>. |
227 RTCErrorOr(T value) : value_(std::move(value)) {} | 227 RTCErrorOr(T&& value) : value_(std::move(value)) {} |
228 | 228 |
229 // Delete the copy constructor and assignment operator; there aren't any use | 229 // Delete the copy constructor and assignment operator; there aren't any use |
230 // cases where you should need to copy an RTCErrorOr, as opposed to moving | 230 // cases where you should need to copy an RTCErrorOr, as opposed to moving |
231 // it. Can revisit this decision if use cases arise in the future. | 231 // it. Can revisit this decision if use cases arise in the future. |
232 RTCErrorOr(const RTCErrorOr& other) = delete; | 232 RTCErrorOr(const RTCErrorOr& other) = delete; |
233 RTCErrorOr& operator=(const RTCErrorOr& other) = delete; | 233 RTCErrorOr& operator=(const RTCErrorOr& other) = delete; |
234 | 234 |
235 // Move constructor and move-assignment operator. | 235 // Move constructor and move-assignment operator. |
236 // | 236 // |
237 // Visual Studio doesn't support "= default" with move constructors or | 237 // Visual Studio doesn't support "= default" with move constructors or |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 } | 291 } |
292 | 292 |
293 private: | 293 private: |
294 RTCError error_; | 294 RTCError error_; |
295 T value_; | 295 T value_; |
296 }; | 296 }; |
297 | 297 |
298 } // namespace webrtc | 298 } // namespace webrtc |
299 | 299 |
300 #endif // WEBRTC_API_RTCERROR_H_ | 300 #endif // WEBRTC_API_RTCERROR_H_ |
OLD | NEW |