| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 RTCErrorOr(RTCErrorOr&& other) = default; | 236 // |
| 237 RTCErrorOr& operator=(RTCErrorOr&& other) = default; | 237 // Visual Studio doesn't support "= default" with move constructors or |
| 238 // assignment operators (even though they compile, they segfault), so define |
| 239 // them explicitly. |
| 240 RTCErrorOr(RTCErrorOr&& other) |
| 241 : error_(std::move(other.error_)), value_(std::move(other.value_)) {} |
| 242 RTCErrorOr& operator=(RTCErrorOr&& other) { |
| 243 error_ = std::move(other.error_); |
| 244 value_ = std::move(other.value_); |
| 245 return *this; |
| 246 } |
| 238 | 247 |
| 239 // Conversion constructor and assignment operator; T must be copy or move | 248 // Conversion constructor and assignment operator; T must be copy or move |
| 240 // constructible from U. | 249 // constructible from U. |
| 241 template <typename U> | 250 template <typename U> |
| 242 RTCErrorOr(RTCErrorOr<U> other) | 251 RTCErrorOr(RTCErrorOr<U> other) |
| 243 : error_(std::move(other.error_)), value_(std::move(other.value_)) {} | 252 : error_(std::move(other.error_)), value_(std::move(other.value_)) {} |
| 244 template <typename U> | 253 template <typename U> |
| 245 RTCErrorOr& operator=(RTCErrorOr<U> other) { | 254 RTCErrorOr& operator=(RTCErrorOr<U> other) { |
| 246 error_ = std::move(other.error_); | 255 error_ = std::move(other.error_); |
| 247 value_ = std::move(other.value_); | 256 value_ = std::move(other.value_); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 } | 291 } |
| 283 | 292 |
| 284 private: | 293 private: |
| 285 RTCError error_; | 294 RTCError error_; |
| 286 T value_; | 295 T value_; |
| 287 }; | 296 }; |
| 288 | 297 |
| 289 } // namespace webrtc | 298 } // namespace webrtc |
| 290 | 299 |
| 291 #endif // WEBRTC_API_RTCERROR_H_ | 300 #endif // WEBRTC_API_RTCERROR_H_ |
| OLD | NEW |