IntrusivePtr: move nullptr initializer to field declaration

This allows "defaulting" the default constructor, and guarantees that
all constructors really initialize the field to a legal value.
This commit is contained in:
Max Kellermann 2020-02-19 05:36:29 +01:00
parent a20dd12117
commit edb93d1733

View file

@ -44,10 +44,7 @@ public:
// -- constructors, destructors, and assignment operators // -- constructors, destructors, and assignment operators
constexpr IntrusivePtr() noexcept : ptr_(nullptr) constexpr IntrusivePtr() noexcept = default;
{
// nop
}
constexpr IntrusivePtr(std::nullptr_t) noexcept : IntrusivePtr() constexpr IntrusivePtr(std::nullptr_t) noexcept : IntrusivePtr()
{ {
@ -160,7 +157,7 @@ private:
Ref(raw_ptr); Ref(raw_ptr);
} }
pointer ptr_; pointer ptr_ = nullptr;
}; };
/** /**