'Can lambda be used instead of void operator?

I'm wondering about this c++11 example and using operator for algorithm functions (for_each, remove_if etc.). For example, I have 2 blocks:

struct UpdateFunc
{
    void operator () (int i) const
    {
        // blablabla
    }
};

and

constexpr auto UpdateFunc = [](int i) -> void
{
    // blablabla
};

Using this for operator:

UpdateFunc f; for_each(cnt.begin(), cnt.end(), f);

Using this for lambda :

std::for_each(cnt.begin(), cnt.end(), UpdateFunc);

Are these functions the same?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source