diff options
Diffstat (limited to 'runtime/obj_ptr.h')
| -rw-r--r-- | runtime/obj_ptr.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/runtime/obj_ptr.h b/runtime/obj_ptr.h index a03b67bed7..7e52a50582 100644 --- a/runtime/obj_ptr.h +++ b/runtime/obj_ptr.h @@ -48,16 +48,17 @@ class ObjPtr { "must have a least kObjectAlignmentShift bits"); public: - OBJPTR_INLINE ObjPtr() REQUIRES_SHARED(Locks::mutator_lock_) : reference_(0u) {} + OBJPTR_INLINE ObjPtr() : ObjPtr(nullptr) {} + + OBJPTR_INLINE ObjPtr(std::nullptr_t) + : reference_(0u) { + DCHECK(IsNull()); + } // Note: The following constructors allow implicit conversion. This simplifies code that uses // them, e.g., for parameter passing. However, in general, implicit-conversion constructors // are discouraged and detected by clang-tidy. - OBJPTR_INLINE ObjPtr(std::nullptr_t) - REQUIRES_SHARED(Locks::mutator_lock_) - : reference_(0u) {} - template <typename Type, typename = typename std::enable_if_t<std::is_base_of_v<MirrorType, Type>>> OBJPTR_INLINE ObjPtr(Type* ptr) REQUIRES_SHARED(Locks::mutator_lock_); |