Re:std::launder: the most obscure new feature of C++17
by renewiltord on Thursday April 04, 2024 @05:05PM
(#39935797)
Wait this is crazy. What's the legitimate use-case? Man I would hate to work on codebases that have these invariants violated.
[ Parent
| on HN ]
Re:std::launder: the most obscure new feature of C++17
by plorkyeran on Thursday April 04, 2024 @07:45PM
(#39937207)
The original use case was that std::vector's API was specifically designed to make it possible to have a vector of a type with const members, but it turned out to be impossible to implement without hitting UB. std::launder was introduced as a way to make the obvious implementation correct. Since then the object lifetime rules were adjusted to make it unnecessary for that.
Re:std::launder: the most obscure new feature of C++17
by renewiltord on Thursday April 04, 2024 @08:21PM
(#39937430)
Oh interesting. Thank you.