Skip to content

Commit 19b55be

Browse files
committedSep 22, 2020
src: add equality operators for BaseObjectPtr
PR-URL: #33772 Backport-PR-URL: #33965 Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent fb68487 commit 19b55be

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
 

‎src/base_object-inl.h

+14
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,20 @@ BaseObjectPtrImpl<T, kIsWeak>::operator bool() const {
336336
return get() != nullptr;
337337
}
338338

339+
template <typename T, bool kIsWeak>
340+
template <typename U, bool kW>
341+
bool BaseObjectPtrImpl<T, kIsWeak>::operator ==(
342+
const BaseObjectPtrImpl<U, kW>& other) const {
343+
return get() == other.get();
344+
}
345+
346+
template <typename T, bool kIsWeak>
347+
template <typename U, bool kW>
348+
bool BaseObjectPtrImpl<T, kIsWeak>::operator !=(
349+
const BaseObjectPtrImpl<U, kW>& other) const {
350+
return get() != other.get();
351+
}
352+
339353
template <typename T, typename... Args>
340354
BaseObjectPtr<T> MakeBaseObject(Args&&... args) {
341355
return BaseObjectPtr<T>(new T(std::forward<Args>(args)...));

‎src/base_object.h

+5
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ class BaseObjectPtrImpl final {
195195
inline T* operator->() const;
196196
inline operator bool() const;
197197

198+
template <typename U, bool kW>
199+
inline bool operator ==(const BaseObjectPtrImpl<U, kW>& other) const;
200+
template <typename U, bool kW>
201+
inline bool operator !=(const BaseObjectPtrImpl<U, kW>& other) const;
202+
198203
private:
199204
union {
200205
BaseObject* target; // Used for strong pointers.

0 commit comments

Comments
 (0)