Commit 653053aa authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

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
parent e61c2150
......@@ -185,11 +185,6 @@ detail::ScopeGuardImplDecay<F> makeGuard(F&& f) noexcept(
return detail::ScopeGuardImplDecay<F>(static_cast<F&&>(f));
}
/**
* This is largely unneeded if you just use auto for your guards.
*/
typedef detail::ScopeGuardImplBase&& ScopeGuard;
namespace detail {
#if defined(FOLLY_EXCEPTION_COUNT_USE_CXA_GET_GLOBALS) || \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment