Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Here it is on godbolt (using noinline): 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.



It’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.


It'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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: