dpiponi,
@dpiponi@mathstodon.xyz avatar

Let me tell you about my embarrassingly stupid C++ mistake so you don't have to make it:

If X is of type std::optional<T> and Y is of type T you can assign Y to X like so:

X = Y

I sort of don't like that because X and Y are different types.

You can also write

*X = Y

which works because *X is of type T&. Now the types match.

But woe is me! Don't do the latter. If X is an empty optional then *X = Y fails silently.

It's obvious when you think about it for a moment. But when you're thinking about the bigger picture you can forget about the little things.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • ethstaker
  • DreamBathrooms
  • normalnudes
  • magazineikmin
  • InstantRegret
  • GTA5RPClips
  • thenastyranch
  • Youngstown
  • rosin
  • slotface
  • osvaldo12
  • ngwrru68w68
  • kavyap
  • everett
  • megavids
  • Durango
  • Leos
  • cubers
  • mdbf
  • khanakhh
  • tester
  • modclub
  • cisconetworking
  • anitta
  • tacticalgear
  • provamag3
  • JUstTest
  • lostlight
  • All magazines