3 ms·
Here it is on godbolt (using noinline): https://godbolt.org/g/7bskDc https://godbolt.org/g/7bskDc The point I (poorly) was trying to make here was that passing
by evmar 8y ago
Here it is on godbolt (using noinline): https://godbolt.org/g/7bskDc https://godbolt.org/g/7bskDc
The point I (poorly) was trying to make here was that passing things by value in Rust is fairly common, for e.g. Rc<T> or Option<T>, while in the C I've seen you basically never pass structs by value. But I guess, continuing the analogy, in C++ you do pass the equivalent of Rc<T> by value.
- yoklov 8y agoIt’s pretty common in both C and C++ to pass things by value, at least for more modern code. Maybe less common than in Rust, but not by that much.
- cwzwarich 8y agoIt's also common in C++ (at least in some coding styles) to pass large structs by const reference, creating the dilemma of when to pass by value and when to pass by reference, which has no perfect general solution.