Skip to content

Commit 39a5ea2

Browse files
authored
Merge pull request #517 from CJ-Johnson/remake_branch
Update TotW #120 to reflect the OSS availability of absl::Cleanup
2 parents ffa890f + 48a1966 commit 39a5ea2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

_posts/2018-04-20-totw-120.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ Let's suppose you have this code snippet, which seems to be working as expected:
1717
```c++
1818
absl::Status DoSomething() {
1919
absl::Status status;
20-
auto log_on_error = absl::MakeCleanup([&status] {
20+
absl::Cleanup log_on_error = [&status] {
2121
if (!status.ok()) LOG(ERROR) << status;
22-
});
22+
};
2323
status = DoA();
2424
if (!status.ok()) return status;
2525
status = DoB();
@@ -108,9 +108,9 @@ absl::Status DoSomething() {
108108
// The 'return status;' statements will always copy the object and Logger
109109
// will always see the correct value.
110110
absl::Status& status = status_no_nrvo;
111-
auto log_on_error = absl::MakeCleanup([&status] {
111+
absl::Cleanup log_on_error = [&status] {
112112
if (!status.ok()) LOG(ERROR) << status;
113-
});
113+
};
114114
status = DoA();
115115
if (!status.ok()) return status;
116116
status = DoB();

0 commit comments

Comments
 (0)