3 ms·
It's not essentially free https://m.youtube.com/watch?v=rHIkrotSwcc https://m.youtube.com/watch?v=rHIkrotSwcc 17:40
by eska 6y ago
It's not essentially free
https://m.youtube.com/watch?v=rHIkrotSwcc https://m.youtube.com/watch?v=rHIkrotSwcc
17:40
- quietbritishjim 6y agoI'd rather you'd just stated your objection instead of making me watch a bit of video. Thanks for at least including a time stamp. For the benefit of others: Using a std::unique_ptr adds exception handling code to the functions that use it to guarantee cleanup when exceptions are thrown. Of course, that extra code is not actually executed if the exception is not thrown. I was responding to a comment that claimed that std::unique_ptr used locks to transfer ownership, and my objection to that is not disputed by what your saying. You're making the point that exception-safe code is less efficient than exception-unsafe code. I do not know enough about that topic to comment on that matter, I was never trying to say anything about it in my previous comment. But I would like to point out that Rust has an analogue of exceptions: panics (although you can change their behaviour to abort() instead of unwind). So it must have something similar to unique_ptr's unwind handler anyway.
- eska 6y agoNah, you missed the main point, it doesn't deal with exceptions. But since you misuse the downvote feature after I looked for the video and timestamp for you, I guess you don't want to be proven wrong anyway. Have a nice day.
- quietbritishjim 6y agoYou can't downvote direct replies to your comments, you'll notice the downvote button is missing for you on this comment of mine. That must be someone(s) else. What do you mean by "it" in "it doesn't deal with exceptions"? Rust? Or the C++ snippet on the left hand side in the presentation with the shorter assembly output? Edit: Since I'm still apparently not clear on your main point, this might be irrelevant, but here [1] is a Godbolt link showing that Rust functions have similar panic-safe unwind code to the C++ exception unwind code shown in the presentation. Admittedly the Rust version does seem a bit shorter (comparing just the actual function, at the bottom of the Godbolt output) and I'm afraid I don't know enough assembly to be able to analyse the difference. But I think the principle is similar. [1] https://godbolt.org/z/K1xPr3 https://godbolt.org/z/K1xPr3