Re:Why introduce `std::launder` rather than have the compile...
by IiydAbITMvJkqKf on Saturday January 22, 2022 @11:53AM
(#30038321)
Specifically, both shared_ptr and unique_ptr are owning pointers. Using plain old pointers for non-owning variables is idiomatic.
[ Parent
| on HN ]
Re:Why introduce `std::launder` rather than have the compile...
by tialaramex on Saturday January 22, 2022 @02:28PM
(#30039990)
Non-owning pointers are a genuinely useful tool, but as a tool they're more welding torch than hammer, if that's what you needed it's really what you needed - but most often it probably isn't what you needed at all and will cause more harm than good.
So it's strange to provide them with stuff like terse built-in syntax, while not providing anything similar for the thing people will want all the time, ownership. Result: The Right Thing™ is harder to do and wastes visual space compared to the Wrong Thing. A "correct" program ends up full of boilerplate just to get what you'd obviously want.