File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -26,26 +26,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD
26
26
template <class _Func >
27
27
class __scope_guard {
28
28
_Func __func_;
29
- bool __moved_from_;
30
29
31
30
public:
32
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __scope_guard (_Func __func) : __func_(std::move(__func)) {}
31
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __scope_guard (_Func __func) : __func_(std::move(__func)) {}
33
32
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__scope_guard () { __func_ (); }
34
33
35
- __scope_guard (const __scope_guard&) = delete ;
34
+ __scope_guard (const __scope_guard&) = delete ;
35
+ __scope_guard& operator =(const __scope_guard&) = delete ;
36
+ __scope_guard& operator =(__scope_guard&&) = delete ;
36
37
37
- // C++17 has mandatory RVO, so we don't need the move constructor anymore to make __make_scope_guard work.
38
+ // C++14 doesn't have mandatory RVO, so we have to provide a declaration even though no compiler will ever generate
39
+ // a call to the move constructor.
38
40
#if _LIBCPP_STD_VER <= 14
39
- __scope_guard (__scope_guard&& __other) : __func_(__other.__func_) {
40
- _LIBCPP_ASSERT_INTERNAL (!__other.__moved_from_ , " Cannot move twice from __scope_guard" );
41
- __other.__moved_from_ = true ;
42
- }
41
+ __scope_guard (__scope_guard&&);
43
42
#else
44
43
__scope_guard (__scope_guard&&) = delete;
45
44
#endif
46
-
47
- __scope_guard& operator =(const __scope_guard&) = delete ;
48
- __scope_guard& operator =(__scope_guard&&) = delete ;
49
45
};
50
46
51
47
template <class _Func >
You can’t perform that action at this time.
0 commit comments