Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Cyborg)
  • No Skin
Collapse
Brand Logo

CIRCLE WITH A DOT

  1. Home
  2. Uncategorized
  3. "Bill why do you hate optional<T&> so much?" Bill:

"Bill why do you hate optional<T&> so much?" Bill:

Scheduled Pinned Locked Moved Uncategorized
22 Posts 6 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • malwareminigun@infosec.exchangeM malwareminigun@infosec.exchange

    @thephd Pretty sure a lot of the folks who wanted optional<T&> were dogmatic about replacing pointers 🙃. Of course with standardization rarely does everyone want something for the same reason.

    Kinda reminds me of what happened with string_view. Google wants it because they see 1% of fleet-wide CPU for Google being spent in strlen, so they want no brakes. Microsoft wants it because they're pushing GSL and want to shut down memory safety issues so they wanted it to bounds check.

    Not sure how I feel about variant and expected. (Note that variant models a discriminated union and the core language forbids reference members of unions https://eel.is/c++draft/class.union#general-4 )

    sdowney@mastodon.socialS This user is from outside of this forum
    sdowney@mastodon.socialS This user is from outside of this forum
    sdowney@mastodon.social
    wrote last edited by
    #21

    @malwareminigun @thephd

    The variant is the reference type for the iterator for the heterogeneous collection that is std::tuple.

    This works, really, but fails because tuple can hold a reference.

    malwareminigun@infosec.exchangeM 1 Reply Last reply
    0
    • sdowney@mastodon.socialS sdowney@mastodon.social

      @malwareminigun @thephd

      The variant is the reference type for the iterator for the heterogeneous collection that is std::tuple.

      This works, really, but fails because tuple can hold a reference.

      malwareminigun@infosec.exchangeM This user is from outside of this forum
      malwareminigun@infosec.exchangeM This user is from outside of this forum
      malwareminigun@infosec.exchange
      wrote last edited by
      #22

      @Sdowney I'm not sure how useful such an iterator is, particularly given that variant and tuple probably want different answers on the rebind vs. assign-through question. (tuple must be assign-through for std::tie/std::forward_as_tuple et al. to work. But @thephd showed us that variant probably wants rebind instead?)

      I know it's encouraging to think of optional<T> as variant<monostate, T> but assignment is one place I can't mentally make them agree

      1 Reply Last reply
      1
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups