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.

demofox,
@demofox@mastodon.gamedev.place avatar

@dpiponi and good language / library design makes you not have to worry about so many of those little details that don't matter towards doing what you are trying to do.

demofox,
@demofox@mastodon.gamedev.place avatar

@dpiponi I just mean to say, you aren't the one that should be embarrassed about that 😀

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