Integrate review feedback

This commit is contained in:
Dominik Charousset 2019-10-29 21:24:56 +01:00
parent 0f41b063b2
commit 72e15fe4d4
6 changed files with 18 additions and 27 deletions

View file

@ -5,15 +5,6 @@
#include <type_traits>
#include <utility>
// These forward declarations only exist to enable ADL for the Ref and Unref
// functions.
struct IntrusivePtrDummy;
void Ref(IntrusivePtrDummy*);
void Unref(IntrusivePtrDummy*);
// An intrusive, reference counting smart pointer implementation.
template <class T>
class IntrusivePtr {
@ -65,7 +56,7 @@ public:
~IntrusivePtr()
{
if (ptr_)
if ( ptr_ )
Unref(ptr_);
}
@ -76,10 +67,10 @@ public:
// Returns the raw pointer without modifying the reference count and sets
// this to `nullptr`.
pointer release() noexcept
pointer detach() noexcept
{
auto result = ptr_;
if (result)
if ( result )
ptr_ = nullptr;
return result;
}
@ -88,7 +79,7 @@ public:
{
auto old = ptr_;
setPtr(new_value, add_ref);
if (old)
if ( old )
Unref(old);
}