mercredi 2 décembre 2015

Are c++11 lambda targets statically created?

I have a following method:

using async_handler_t = std::function<void(boost::system::error_code, std::size_t)>;
async_handler_t deadlineHandler(boost::system::error_code &ec) {
    return [&ec, this](boost::system::error_code newEc, std::size_t) {
        ec = newEc;
        deadline_.cancel();
    };
}

This is simple asio deadline handler which stops the deadline timer and allows the io_service-run loop to continue (grabbed this from official asio timeout docs).

The question is about how much times the function itself is generated. I understand, that I return a functional object from this method (std::function object) which is created dynamically during runtime but is the target function created only once?

Aucun commentaire:

Enregistrer un commentaire