Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: base/callback_internal.h

Issue 2581943005: Explicitly delete some Callback constructors to improve errors.
Patch Set: MSVC doesn't implement type traits correctly. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« base/callback.h ('K') | « base/callback.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file contains utility functions and classes that help the 5 // This file contains utility functions and classes that help the
6 // implementation, and management of the Callback objects. 6 // implementation, and management of the Callback objects.
7 7
8 #ifndef BASE_CALLBACK_INTERNAL_H_ 8 #ifndef BASE_CALLBACK_INTERNAL_H_
9 #define BASE_CALLBACK_INTERNAL_H_ 9 #define BASE_CALLBACK_INTERNAL_H_
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // Holds the Callback methods that don't require specialization to reduce 72 // Holds the Callback methods that don't require specialization to reduce
73 // template bloat. 73 // template bloat.
74 // CallbackBase<MoveOnly> is a direct base class of MoveOnly callbacks, and 74 // CallbackBase<MoveOnly> is a direct base class of MoveOnly callbacks, and
75 // CallbackBase<Copyable> uses CallbackBase<MoveOnly> for its implementation. 75 // CallbackBase<Copyable> uses CallbackBase<MoveOnly> for its implementation.
76 template <> 76 template <>
77 class BASE_EXPORT CallbackBase<CopyMode::MoveOnly> { 77 class BASE_EXPORT CallbackBase<CopyMode::MoveOnly> {
78 public: 78 public:
79 CallbackBase(CallbackBase&& c); 79 CallbackBase(CallbackBase&& c);
80 CallbackBase& operator=(CallbackBase&& c); 80 CallbackBase& operator=(CallbackBase&& c);
81 81
82 CallbackBase(const CallbackBase&) = delete;
83 CallbackBase& operator=(const CallbackBase&) = delete;
dcheng 2016/12/19 11:07:40 Deleting it in the Callback template helper itself
brucedawson 2016/12/19 19:16:00 Simple is probably better in that case.
84
82 explicit CallbackBase(const CallbackBase<CopyMode::Copyable>& c); 85 explicit CallbackBase(const CallbackBase<CopyMode::Copyable>& c);
83 CallbackBase& operator=(const CallbackBase<CopyMode::Copyable>& c); 86 CallbackBase& operator=(const CallbackBase<CopyMode::Copyable>& c);
84 87
85 // Returns true if Callback is null (doesn't refer to anything). 88 // Returns true if Callback is null (doesn't refer to anything).
86 bool is_null() const { return bind_state_.get() == NULL; } 89 bool is_null() const { return bind_state_.get() == NULL; }
87 explicit operator bool() const { return !is_null(); } 90 explicit operator bool() const { return !is_null(); }
88 91
89 // Returns true if the callback invocation will be nop due to an cancellation. 92 // Returns true if the callback invocation will be nop due to an cancellation.
90 // It's invalid to call this on uninitialized callback. 93 // It's invalid to call this on uninitialized callback.
91 bool IsCancelled() const; 94 bool IsCancelled() const;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 ~CallbackBase() {} 133 ~CallbackBase() {}
131 }; 134 };
132 135
133 extern template class CallbackBase<CopyMode::MoveOnly>; 136 extern template class CallbackBase<CopyMode::MoveOnly>;
134 extern template class CallbackBase<CopyMode::Copyable>; 137 extern template class CallbackBase<CopyMode::Copyable>;
135 138
136 } // namespace internal 139 } // namespace internal
137 } // namespace base 140 } // namespace base
138 141
139 #endif // BASE_CALLBACK_INTERNAL_H_ 142 #endif // BASE_CALLBACK_INTERNAL_H_
OLDNEW
« base/callback.h ('K') | « base/callback.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698