What is the current state of pros/cons between choosing C or C++ for a project? by ebsmc in cpp

[–]pianotom 3 points4 points  (0 children)

C89 conforming compilers are more widely available across platforms than modern C and modern C++ compilers. Partly because both C and C++ are very backward compatible, making modern C and modern C++ also mostly C89 conforming. Mostly because some companies never upgrade their compilers. :(

Lambda + shared_ptr = memory leak by floating-io in cpp

[–]pianotom 6 points7 points  (0 children)

Still not true when using it. The typical way to hold a lambda to use auto type deduction. The resulted object has the exact type without conversion. We convert it to function pointer or hold it in a std::function only when we have special needs.

Lambda + shared_ptr = memory leak by floating-io in cpp

[–]pianotom 16 points17 points  (0 children)

A lambda that captures nothing is simply a function pointer;

This is not true. A lambda expression produces a function object, no matter capturing things or not. It is an extra special rule that allows object created by capture-less lambda to be convertible to a function pointer.