Skip to content
Merged
Changes from all commits
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
8 changes: 4 additions & 4 deletions _posts/2018-04-20-totw-120.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Let's suppose you have this code snippet, which seems to be working as expected:
```c++
absl::Status DoSomething() {
absl::Status status;
auto log_on_error = absl::MakeCleanup([&status] {
absl::Cleanup log_on_error = [&status] {
if (!status.ok()) LOG(ERROR) << status;
});
};
status = DoA();
if (!status.ok()) return status;
status = DoB();
Expand Down Expand Up @@ -108,9 +108,9 @@ absl::Status DoSomething() {
// The 'return status;' statements will always copy the object and Logger
// will always see the correct value.
absl::Status& status = status_no_nrvo;
auto log_on_error = absl::MakeCleanup([&status] {
absl::Cleanup log_on_error = [&status] {
if (!status.ok()) LOG(ERROR) << status;
});
};
status = DoA();
if (!status.ok()) return status;
status = DoB();
Expand Down