Normally, if you have a lambda and forget to use it, you'll get a warning (if enabled) like any other unused variable.
auto foo = [](){};
would generate warning: unused variable 'foo' or similar.
However, if the lambda captures have side-effects (like bumping the ref count of a shared_ptr), you won't get the warning.
auto x = std::make_shared<int>(23);
auto foo = [x](){ bar(*x); };
So, short of creating my own [[nodiscard]] wrapper for function objects, are there any extra warning flags I'm missing or static analysis tools that'd pick up this mistake?
Mainly a gcc user, although would be building with clang as well off the same code base.