Previously:
RegisteredPrefix::Unregistrator bindedUnregistrator =
bind(unregistrator, m_face.m_nfdController, unregisterParameters, _1, _2,
options);
New version:
RegisteredPrefix::Unregistrator bindedUnregistrator =
[this, &unregistrator, unregisterParameters, options] (const Controller::CommandSucceedCallback& successCallback,
const Controller::CommandFailCallback& failCallback)
{
((*this->m_face.m_nfdController).*unregistrator)(unregisterParameters, successCallback, failCallback, options);
};
I have been asked to revert this part and use again bind function instead of lambda.
========
My answer:
Before changing the Controller attribute we had a pointer and it made sense to allow it to be copied into the bind function. But now that we have a unique_ptr
we cannot copy the pointer, nor can we copy the object inside the pointer because Controller is noncopyable.
If you think we should keep the shared I see 2 solutions:
Keep the pointer instead of having a unique_ptr
Change the unique_ptr
to a shared_ptr
so it can be copied around
With the lambda what we do is to copy the reference of the face_impl
in order to use it. Can we do this with the bind?