3 ms·
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/pZde
by steveklabnik 10y 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 https://godbolt.org/g/pZde2A is roughly it.
Actually, https://godbolt.org/g/1vcMeG 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 https://godbolt.org/g/cVDjQH
movabs rdi, 21474836480
call example::f1@PLT
vs
mov edi, 5
pop rbp
jmp example::f2@PLT
so, yup.
- typon 10y agoThank you! This is really cool.