File tree Expand file tree Collapse file tree 1 file changed +4
-14
lines changed Expand file tree Collapse file tree 1 file changed +4
-14
lines changed Original file line number Diff line number Diff line change 18
18
#ifndef SWIFT_BASIC_DEFER_H
19
19
#define SWIFT_BASIC_DEFER_H
20
20
21
- #include < type_traits >
21
+ #include " llvm/ADT/ScopeExit.h "
22
22
23
23
namespace swift {
24
- template <typename F>
25
- class DoAtScopeExit {
26
- F Fn;
27
- void operator =(DoAtScopeExit&) = delete ;
28
- public:
29
- DoAtScopeExit (F &&Fn) : Fn(std::move(Fn)) {}
30
- ~DoAtScopeExit () {
31
- Fn ();
32
- }
33
- };
34
-
35
24
namespace detail {
36
25
struct DeferTask {};
37
26
template <typename F>
38
- DoAtScopeExit<typename std::decay<F>::type> operator +(DeferTask, F&& fn) {
39
- return DoAtScopeExit<typename std::decay<F>::type>(std::move (fn));
27
+ auto operator +(DeferTask, F &&fn) ->
28
+ decltype (llvm::make_scope_exit(std::forward<F>(fn))) {
29
+ return llvm::make_scope_exit (std::forward<F>(fn));
40
30
}
41
31
}
42
32
} // end namespace swift
You can’t perform that action at this time.
0 commit comments