▲ | fluoridation 5 days ago | ||||||||||||||||||||||||||||||||||||||||||||||||||||
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. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | sunshowers 5 days ago | parent [-] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
The ergonomics matter a lot. Of course a lambda is equivalent to a functor that stores a local reference, but making errors with lambdas requires disturbingly little friction. In any case, if you want safety and performance, use Rust. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|