Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make fml/status_or.h compatible with .clang_tidy. #48002

Merged
merged 6 commits into from
Nov 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions fml/status_or.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ namespace fml {
template <typename T>
class StatusOr {
public:
StatusOr(const T& value) : status_(), value_(value) {}
StatusOr(const Status& status) : status_(status), value_() {}
explicit StatusOr(const T& value) : status_(), value_(value) {}
explicit StatusOr(const Status& status) : status_(status), value_() {}

StatusOr(const StatusOr&) = default;
StatusOr(StatusOr&&) = default;
Expand Down Expand Up @@ -63,13 +63,17 @@ class StatusOr {
bool ok() const { return status_.ok(); }

const T& value() const {
FML_CHECK(status_.ok());
return value_.value();
if (status_.ok()) {
return value_.value();
}
FML_LOG(FATAL) << "StatusOr::value() called on error Status";
}

T& value() {
FML_CHECK(status_.ok());
return value_.value();
if (status_.ok()) {
return value_.value();
}
FML_LOG(FATAL) << "StatusOr::value() called on error Status";
}

private:
Expand Down