3 ms·
Yes I would. In modern C++ we use exceptions and RAII for automatic cleanup.
by softc 10y ago
Yes I would. In modern C++ we use exceptions and RAII for automatic cleanup.
- mmstick 10y agoExceptions have high cost so I don't see where you are coming from. Rust's RAII goes further along than C++'s. C++ is playing a game of catchup to steal the move semantics from Rust.
- olejorgenb 10y agoAccording to http://stackoverflow.com/a/13836329/1517969 http://stackoverflow.com/a/13836329/1517969 modern c++ exceptions are free when no throw occurs.
- mmstick 10y agoIn addition, Rust Results/Options are free when no throw occurs. So the argument is moot.
- softc 10y agoNo they aren't, you must issue a compare instruction to verify the result was successful.
- oconnor663 10y agoDo you know whether branch prediction makes them effectively free, in places where the result is almost always successful?
- softc 10y agoException handling in C++ is absolutely zero-cost when no exception occurs. Look up the Itanium ABI. In Rust, even if no error occurs, the return value must still be checked. Additionally, Move semantics were borrowed from C++, not the other way around.