Cut the ScopeGuard alias now that we have auto
Summary: [Folly] Cut the `ScopeGuard` alias now that we have `auto`. This form works because of hidden lifetime extension: ```lang=c++ folly::ScopeGuard guard = folly::makeGuard([] { /*...*/ }); // ... // guard falls out of scope ``` But this form would not work correctly: ```lang=c++ folly::ScopeGuard guard = folly::makeGuard([] { /*...*/ }); std::async(std::launch::async, [guard = std::move(guard)] {}); ``` Because `folly::ScopeGuard` is an rvalue-reference-to-base. We have `auto`, so just remove `folly::ScopeGuard`. This form works correctly: ```lang=c++ auto guard = folly::makeGuard([] { /*...*/ }); std::async(std::launch::async, [guard = std::move(guard)] {}); ``` Reviewed By: igorsugak Differential Revision: D6690070 fbshipit-source-id: 54e32b300d36fce4eb95a59f1828819afe312ec0
Showing
Please register or sign in to comment