Use different Status::Error in Result.

GitOrigin-RevId: 223a42d0bbfa777a821d29d4996e27b1d8fd8fff
This commit is contained in:
levlam 2018-07-08 18:55:12 +03:00
parent e0c7e0b930
commit 0c907b38a8

View File

@ -311,7 +311,7 @@ class Status {
template <class T = Unit> template <class T = Unit>
class Result { class Result {
public: public:
Result() : status_(Status::Error()) { Result() : status_(Status::Error<1>()) {
} }
template <class S, std::enable_if_t<!std::is_same<std::decay_t<S>, Result>::value, int> = 0> template <class S, std::enable_if_t<!std::is_same<std::decay_t<S>, Result>::value, int> = 0>
Result(S &&x) : status_(), value_(std::forward<S>(x)) { Result(S &&x) : status_(), value_(std::forward<S>(x)) {
@ -326,7 +326,7 @@ class Result {
new (&value_) T(std::move(other.value_)); new (&value_) T(std::move(other.value_));
other.value_.~T(); other.value_.~T();
} }
other.status_ = Status::Error(); other.status_ = Status::Error<2>();
} }
Result &operator=(Result &&other) { Result &operator=(Result &&other) {
if (status_.is_ok()) { if (status_.is_ok()) {
@ -344,7 +344,7 @@ class Result {
other.value_.~T(); other.value_.~T();
} }
status_ = std::move(other.status_); status_ = std::move(other.status_);
other.status_ = Status::Error(); other.status_ = Status::Error<3>();
return *this; return *this;
} }
~Result() { ~Result() {
@ -375,7 +375,7 @@ class Result {
Status move_as_error() TD_WARN_UNUSED_RESULT { Status move_as_error() TD_WARN_UNUSED_RESULT {
CHECK(status_.is_error()); CHECK(status_.is_error());
SCOPE_EXIT { SCOPE_EXIT {
status_ = Status::Error(); status_ = Status::Error<4>();
}; };
return std::move(status_); return std::move(status_);
} }