CPP RSPEC-5019 - Should it be positive when using a method from captured reference?

Considering this code:


m_frameProcessor->setFrameCallback([&](unsigned char* data) noexcept

                                           {

                                               onNewFrame(reinterpret_cast<unsigned short*>(data));

                                               return EXIT_SUCCESS;

                                           });

This will pop RSPEC-5019 and RSPEC-3608 because of the general capture [&] . But the documentation doesn’t suggest a preferred way to pass anything else in case of a method call ( onNewFrame is a method from this ). I wonder if it is intended and there is a better way to capture a method for a lambda, or if it is a false positive?

Hi Matthieu,

The problem is not capturing this. The problem is capturing this silently and implicitly.
So if you need to call a method you should capture this - just do it explicitly in the captures list.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.