Skip to content

Commit

Permalink
Added std::nullptr_t constructors to weak pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliom committed Jul 12, 2024
1 parent ef71d6c commit 2e017a6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions BasicCppLibrary/include/BasicMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ namespace bsc

public:
unique_ptr() : m_ptr(nullptr) {}
constexpr unique_ptr(std::nullptr_t) noexcept : m_ptr(nullptr) {}
unique_ptr(T* ptr) : m_ptr(ptr) {}

~unique_ptr()
Expand Down Expand Up @@ -304,6 +305,7 @@ namespace bsc

public:
shared_ptr() : m_cblock(nullptr) {}
constexpr shared_ptr(std::nullptr_t) noexcept : m_cblock(nullptr) {}
shared_ptr(T* ptr) : m_cblock(new control_block<T>(ptr)) {}

~shared_ptr()
Expand Down Expand Up @@ -400,6 +402,7 @@ namespace bsc

public:
weak_ptr() : m_cblock(nullptr) {}
constexpr weak_ptr(std::nullptr_t) noexcept : m_cblock(nullptr) {}
weak_ptr(shared_ptr<T> shared) : m_cblock(shared.m_cblock)
{
if (m_cblock != nullptr)
Expand Down

0 comments on commit 2e017a6

Please sign in to comment.