Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Ambraven :verifinking:​
@Ambraven@social.mochi.academy  ·  activity timestamp 2 days ago

Looking into std::variant in c++17.

Is this the cpp "new" way to do union types?

What are the advantages ?

#Cpp #programming

  • Copy link
  • Flag this post
  • Block
🌅 Aurore, la trans-parente 🤱
@ZeldAurore@mastodon.opportunis.me replied  ·  activity timestamp 2 days ago

@Ambraven Si ta fonction prends un variant, tu lui passes un objet d'un des types de ce variant de manière simple, sans avoir besoin de le transformer en variant<,>.
Si chaque types dans le variant à une méthode genre to_string(), tu peux appeler la méthode to_string du variant sans chercher à savoir de quel type il est.
Globalement c'est une manière transparente d'avoir des unions de type.

  • Copy link
  • Flag this comment
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0-rc.3.13 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login