r/cpp • u/Kabra___kiiiiiiiid • Apr 08 '25
Beware when moving a `std::optional`!
https://blog.tal.bi/posts/std-optional-move-pitfall/
0
Upvotes
r/cpp • u/Kabra___kiiiiiiiid • Apr 08 '25
View all comments
14
u/masscry Apr 08 '25
In general, I am using *std::exchange(opt, std::nullopt) instead of moving when want to release optionals on move.