Task #2112
closedFace: use lambda expression and smart pointers
100%
Description
Enhance Face and Face::Impl with C++11 features:
- use lambda expression instead of 
bindwhere applicable - use 
unique_ptron member fields where they are currently regular pointers - use 
unique_ptrinstead ofshared_ptrwhere applicable 
      
      Updated by Joao Pereira over 10 years ago
      
    
    - Status changed from New to In Progress
 - Start date set to 05/18/2015
 
Start changes
      
      Updated by Joao Pereira over 10 years ago
      
    
    - Status changed from In Progress to Code review
 - % Done changed from 0 to 100
 
      
      Updated by Joao Pereira over 10 years ago
      
    
    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_ptrChange the
unique_ptrto ashared_ptrso 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?
      
      Updated by Davide Pesavento over 10 years ago
      
    
    
    
      
      Updated by Junxiao Shi over 10 years ago
      
    
    - Status changed from Code review to Closed