Hacker News new | ask | show | jobs
by steveklabnik 3379 days ago

  void f(std::variant<int, char>)
would be

  f(x: IntOrChar)
roughly in Rust, I'm too lazy to make the types _exactly_ the same, but https://godbolt.org/g/pZde2A is roughly it.

Actually, https://godbolt.org/g/1vcMeG might be even better to compare; I'm not an expert, but looks like the only difference is in the size.

last one, adding inline(never) so you can see the calls in main: https://godbolt.org/g/cVDjQH

  movabs  rdi, 21474836480
  call    example::f1@PLT
vs

  mov     edi, 5
  pop     rbp
  jmp     example::f2@PLT
so, yup.
1 comments

Thank you! This is really cool.