Я использую
Код: Выделить всё
find_if
Код: Выделить всё
find_if
Код: Выделить всё
auto Finger::dataRef() const -> FingerData const &
{
return fingerData; // member variable, and lifetime is the lifetime of the program
}
Код: Выделить всё
auto findTap(
std::vector & taps,
controls::FingerData const & finger
) -> std::vector::iterator
{
return std::find_if(begin(taps), end(taps), [&](Tap & t) {
return t.getFingerId() == finger.fingerId;
});
}
Код: Выделить всё
auto tap = findTap(taps, finger.dataRef());
Код: Выделить всё
auto & fId = x.fingerId;
auto tap = std::find_if(begin(taps), end(taps), [&](auto & t) {
return t.getFingerId() == fId;
});
auto tap = findTap(taps, finger.dataRef());
Код: Выделить всё
reference_wrapper
I tried different ways to pass in the finger, but the only approach that solves my problem is to create a reference to the finger ID outside the lambda and then use that directly.
This first video is from MSVC, which is causing rapid flickering that the recorder couldn't capture very well. You can see it when options and exit are alternating even though only one of those is actually selected. I'm ignoring the result of
Код: Выделить всё
find_if

This second video is also from MSVC but only when I pass in the references directly rather than through the finger reference.

Источник: https://stackoverflow.com/questions/781 ... ith-window