diff --git a/TESTS/mbed_platform/SharedPtr/main.cpp b/TESTS/mbed_platform/SharedPtr/main.cpp index 3afc936763..35d40e48b1 100644 --- a/TESTS/mbed_platform/SharedPtr/main.cpp +++ b/TESTS/mbed_platform/SharedPtr/main.cpp @@ -65,7 +65,7 @@ void test_single_sharedptr_lifetime() */ void test_instance_sharing() { - SharedPtr s_ptr1(NULL); + SharedPtr s_ptr1(nullptr); // Sanity-check value of counter TEST_ASSERT_EQUAL(0, TestStruct::s_count); @@ -80,7 +80,7 @@ void test_instance_sharing() TEST_ASSERT_EQUAL(1, TestStruct::s_count); - s_ptr1 = NULL; + s_ptr1 = nullptr; // Destroy shared pointer TEST_ASSERT_EQUAL(0, TestStruct::s_count); diff --git a/platform/SharedPtr.h b/platform/SharedPtr.h index edaa8198b3..74ae53a90f 100644 --- a/platform/SharedPtr.h +++ b/platform/SharedPtr.h @@ -75,6 +75,13 @@ public: { } + /** + * @brief Create empty SharedPtr not pointing to anything. + */ + constexpr SharedPtr(std::nullptr_t) : SharedPtr() + { + } + /** * @brief Create new SharedPtr * @param ptr Pointer to take control over