Skip to content
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

etl::unique_ptr reset #921

Closed
fermentedfly opened this issue Jul 16, 2024 · 3 comments
Closed

etl::unique_ptr reset #921

fermentedfly opened this issue Jul 16, 2024 · 3 comments

Comments

@fermentedfly
Copy link
Contributor

fermentedfly commented Jul 16, 2024

Hi,

I have some cases where I need to clear (reset(nullptr)) the content of a unique_ptr which may or may not be already cleared.
If it is already clear the assertion in assert(p_ != p); is triggered.
I was wondering if this should be the case since clearing what is already clear does seem fine to me.
I propose the assertion to be changed to assert(p_ == nullptr || p_ != p);, or maybe implement the overloaded void reset( std::nullptr_t = nullptr )
What do you think?

Regards,
Manuel

@jwellbelove
Copy link
Contributor

Sounds reasonable

@fermentedfly
Copy link
Contributor Author

Ok, do you want me to send you a PR?

jwellbelove pushed a commit that referenced this issue Jul 19, 2024
* Add an etl::nullptr_t type

* etlcpp/etl issue #921 (etl::unique_ptr reset): add etl::unique_ptr(...)::reset(ETL_NULLPTR)

Remove default argument for the normal reset method of etl::unique_ptr (sorry, didn't notice 😬)

Silence the unused argument warning

Fix operator =(nullptr)

Replace the nullptr_t enum with a class which acts more similar to C++11 nullptr

* Add member pointer support and delete the addressof operator

* "Delete" etl::addressof(ETL_NULLPTR)

* Ensure compatibility with C++98

* ACTUALLY ensure compatibility with C++98

I'm stupid :/

* Correct definition according to cppreference
jwellbelove pushed a commit that referenced this issue Jul 28, 2024
* Add an etl::nullptr_t type

* etlcpp/etl issue #921 (etl::unique_ptr reset): add etl::unique_ptr(...)::reset(ETL_NULLPTR)

Remove default argument for the normal reset method of etl::unique_ptr (sorry, didn't notice 😬)

Silence the unused argument warning

Fix operator =(nullptr)

Replace the nullptr_t enum with a class which acts more similar to C++11 nullptr

* Add member pointer support and delete the addressof operator

* "Delete" etl::addressof(ETL_NULLPTR)

* Ensure compatibility with C++98

* ACTUALLY ensure compatibility with C++98

I'm stupid :/

* Correct definition according to cppreference
@fermentedfly
Copy link
Contributor Author

Thanks for implementing :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants