jeudi 3 octobre 2019

C++ Lambda expressions: capture by ref overhead

I figured out that in project I worked a lot of places where lambda expressions capture pointer on this, but doesn't use it. Does it lead to some kind overhead like pointer copy, or optimized by compiller?

void MyClass::SomeFunction()
{
    ...
    grid->ForEachItem([this](const Item& item)
    {
        // Some code doesn't use this
    }
}

And the same question dedicated to capture all by reference [&]

Aucun commentaire:

Enregistrer un commentaire