-
Notifications
You must be signed in to change notification settings - Fork 3k
SharedPtr: add nullptr constructor #12048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ARMmbed/mbed-os#12048 will require that `SharedPtr` users use `nullptr` rather than `NULL` or `0`, which will no longer compile. Update example in code. Change can be made to docs whenever, as `nullptr` form works now.
ARMmbed/mbed-os#12048 will require that `SharedPtr` users use `nullptr` rather than `NULL` or `0`, which will no longer compile. Update example in code. Change can be made to docs whenever, as `nullptr` form works now.
ARMmbed/mbed-os#12048 will require that `SharedPtr` users use `nullptr` rather than `NULL` or `0`, which will no longer compile. Update example in code. Change can be made to docs whenever, as `nullptr` form works now.
For consistency with `std::shared_ptr`, and `mbed::Callback`, and as a potential optimisation aid, give `SharedPtr` a distinct constructor for `nullptr`.
@kjbracey-arm, thank you for your changes. |
f14178b
to
2b4b723
Compare
Looks good, but it's a breaking change. |
/** | ||
* @brief Create empty SharedPtr not pointing to anything. | ||
*/ | ||
constexpr SharedPtr(std::nullptr_t) : SharedPtr() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use constexpr to the default constructor as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed.
I'm doing that in #12037 - I've split the PRs cos this one is a breaking change, and that one isn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And, actually, the constexpr
here is ineffective until the default constructor it delegates to is made constexpr
. But it's harmless if added alone.
CI started |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
Summary of changes
For consistency with
std::shared_ptr
, andmbed::Callback
, and as apotential optimisation aid, give
SharedPtr
a distinct constructor fornullptr
.Impact of changes
nullptr
overload.Migration actions required
nullptr
overload meansSharedPtr(NULL)
orSharedPtr(0)
will no longer work; users must useSharedPtr(nullptr)
orSharedPtr()
.Documentation
Docs example updated in ARMmbed/mbed-os-5-docs#1183
Pull request type
Test results
Reviewers