▲ | sunshowers 5 days ago | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I'm glad, but my problem is with the claim that modern C++ is safer. They added new features that are very easy to misuse. Meanwhile in Rust you can freely borrow from the stack in closures, and the borrow checker ensures that you'll not screw up. That's what (psychological) safety feels like. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | fluoridation 5 days ago | parent [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Lambdas are syntactic sugar over functors, and it was possible all along to define a functor that stores a local address and then return it from the scope, thus leaving a dangling pointer. They don't introduce any new places for bugs to creep in, other than confusing programmers who are used to garbage-collected languages. That C++11 is safer than C++98 is still true, as this and other convenience features make it harder to introduce bugs from boilerplate code. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|