Timeline for answer to std::optional - construct empty with curly brackets {} or std::nullopt? by darune
Current License: CC BY-SA 4.0
Post Revisions
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 27, 2019 at 17:45 | comment | added | Marc Glisse | Slowing down the program so bugs are a bit more likely to be found (are they? tooling is getting quite good at detecting uses of uninitialized memory) would be fine for some debug mode, not for the maximum performance mode. | |
| Sep 27, 2019 at 14:39 | comment | added | ofo |
Although this may work fine in practice, your first example invokes UB as *this doesn't contain a value. Also, you could have the same property with std::optional<X*>{{}}, where you explicitly zero-initialize when it makes sense and you really need it.
|
|
| Sep 27, 2019 at 12:14 | history | edited | darune | CC BY-SA 4.0 |
added 14 characters in body
|
| Sep 27, 2019 at 12:08 | history | edited | darune | CC BY-SA 4.0 |
added 14 characters in body
|
| Sep 27, 2019 at 12:02 | history | edited | darune | CC BY-SA 4.0 |
added 30 characters in body
|
| Sep 27, 2019 at 11:51 | comment | added | Martin Bonner supports Monica | "a guarenteed seg fault" - no it isn't. I've worked on platforms where writing through a null pointer doesn't cause a seg-fault; it just sets an interrupt vector. | |
| Sep 27, 2019 at 11:26 | history | edited | darune | CC BY-SA 4.0 |
added 366 characters in body
|
| Sep 27, 2019 at 11:05 | history | edited | darune | CC BY-SA 4.0 |
added 13 characters in body
|
| Sep 27, 2019 at 10:48 | history | edited | darune | CC BY-SA 4.0 |
added 64 characters in body
|
| Sep 27, 2019 at 9:54 | history | answered | darune | CC BY-SA 4.0 |