Bug
Bug 1355739 - Part1: Pass lvalue callable object into MakeScopeExit should be allowd.
MozReview-Commit-ID: AuB5MCXs0Fu
--- a/mfbt/ScopeExit.h
+++ b/mfbt/ScopeExit.h
@@ -119,17 +119,20 @@ public:
private:
explicit ScopeExit(const ScopeExit&) = delete;
ScopeExit& operator=(const ScopeExit&) = delete;
ScopeExit& operator=(ScopeExit&&) = delete;
};
template <typename ExitFunction>
-ScopeExit<ExitFunction>
+ScopeExit<typename RemoveConst<typename RemoveReference<ExitFunction>::Type>::Type>
MakeScopeExit(ExitFunction&& exitFunction)
{
- return ScopeExit<ExitFunction>(mozilla::Move(exitFunction));
+ using RemoveCRType =
+ typename RemoveConst<typename RemoveReference<ExitFunction>::Type>::Type;
+ RemoveCRType exitFunc = exitFunction;
+ return ScopeExit<RemoveCRType>(mozilla::Move(exitFunc));
}
} /* namespace mozilla */
#endif /* mozilla_ScopeExit_h */