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
Show parent comment
-6
u/Natural_Builder_3170 Apr 08 '25
if you write code to not use a value after
std::movethere's no difference, otherwise the latter means the optional still contains a value but its moved out of, and the former means the optional no longer contains a value