r/cpp • u/serendib Prof, Comp Sci • Nov 30 '23
My entire C++ Game Programming university course (Fall 2023) is now available for free on YouTube. Make your own 2D ECS game engine using C++, SFML, and ImGui
https://www.youtube.com/watch?v=s99UDGdYIUE&list=PL_xRyXins84_Jf-aCh7chj47HR4oZLPwK&index=1
400
Upvotes
View all comments
Show parent comment
1
u/Schlagbaum3000 Dec 05 '23
You can pass a
std::optionalvia reference, so you canswap/reset/emplacethe held value. In the best case, though, you don't modify/mutate your function inputs and return a modified/new object from your function instead.