mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Ensure that RTCErrorOr<T, E> doesn't require T to be default constructible
Bug: webrtc:15214 Change-Id: Ic2d61c64d770943472374f61ad71249e88c3f6f6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/307520 Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Auto-Submit: Florent Castelli <orphis@webrtc.org> Cr-Commit-Position: refs/heads/main@{#40223}
This commit is contained in:
parent
0740048170
commit
be316dab88
1 changed files with 4 additions and 4 deletions
|
@ -308,23 +308,23 @@ class RTCErrorOr {
|
||||||
// the stack.
|
// the stack.
|
||||||
const T& value() const {
|
const T& value() const {
|
||||||
RTC_DCHECK(ok());
|
RTC_DCHECK(ok());
|
||||||
return value_;
|
return *value_;
|
||||||
}
|
}
|
||||||
T& value() {
|
T& value() {
|
||||||
RTC_DCHECK(ok());
|
RTC_DCHECK(ok());
|
||||||
return value_;
|
return *value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Moves our current value out of this object and returns it, or DCHECK-fails
|
// Moves our current value out of this object and returns it, or DCHECK-fails
|
||||||
// if !this->ok().
|
// if !this->ok().
|
||||||
T MoveValue() {
|
T MoveValue() {
|
||||||
RTC_DCHECK(ok());
|
RTC_DCHECK(ok());
|
||||||
return std::move(value_);
|
return std::move(*value_);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RTCError error_;
|
RTCError error_;
|
||||||
T value_;
|
absl::optional<T> value_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
Loading…
Reference in a new issue