Timeline for answer to Trying to return a `std::unique_ptr` constructed with `NULL` by Toby Speight
Current License: CC BY-SA 3.0
Post Revisions
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 2, 2015 at 7:56 | audit | Low quality answers | |||
| Sep 2, 2015 at 8:17 | |||||
| Aug 25, 2015 at 14:02 | comment | added | Lightness Races in Orbit | I really think that this, while a valid suggestion, is not a fix for the OP's problem (whatever that may be). | |
| Aug 25, 2015 at 13:24 | vote | accept | erip | ||
| Aug 25, 2015 at 13:07 | comment | added | Chris Drew |
When I convert std::unique_ptr<Foo>(NULL) to bool I do get false.
|
|
| Aug 25, 2015 at 13:02 | history | edited | Toby Speight | CC BY-SA 3.0 |
delete 0 is perfectly legal, like free(0)
|
| Aug 25, 2015 at 13:00 | comment | added | Sneftel | A NULLed shared_ptr is valid, but it's hardly idiomatic. | |
| Aug 25, 2015 at 12:59 | comment | added | Lightness Races in Orbit |
There's nothing wrong with attempting to delete an object at "the NULL address". Frankly I don't see why the OP's code shouldn't work.
|
|
| Aug 25, 2015 at 12:57 | history | answered | Toby Speight | CC BY-SA 3.0 |