Skip to content

Commit 0770798

Browse files
authored
Merge pull request #12048 from kjbracey-arm/sharedptr_nullptr
SharedPtr: add nullptr constructor
2 parents 6b4262f + 2b4b723 commit 0770798

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

TESTS/mbed_platform/SharedPtr/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void test_single_sharedptr_lifetime()
6565
*/
6666
void test_instance_sharing()
6767
{
68-
SharedPtr<TestStruct> s_ptr1(NULL);
68+
SharedPtr<TestStruct> s_ptr1(nullptr);
6969

7070
// Sanity-check value of counter
7171
TEST_ASSERT_EQUAL(0, TestStruct::s_count);
@@ -80,7 +80,7 @@ void test_instance_sharing()
8080

8181
TEST_ASSERT_EQUAL(1, TestStruct::s_count);
8282

83-
s_ptr1 = NULL;
83+
s_ptr1 = nullptr;
8484

8585
// Destroy shared pointer
8686
TEST_ASSERT_EQUAL(0, TestStruct::s_count);

platform/SharedPtr.h

+7
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ class SharedPtr {
7575
{
7676
}
7777

78+
/**
79+
* @brief Create empty SharedPtr not pointing to anything.
80+
*/
81+
constexpr SharedPtr(std::nullptr_t) : SharedPtr()
82+
{
83+
}
84+
7885
/**
7986
* @brief Create new SharedPtr
8087
* @param ptr Pointer to take control over

0 commit comments

Comments
 (0)