Github user arpadboda commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/428#discussion_r228855333
  
    --- Diff: libminifi/src/FlowController.cpp ---
    @@ -911,11 +911,18 @@ uint64_t FlowController::getUptime() {
     }
     
     std::vector<BackTrace> FlowController::getTraces() {
    -    std::vector<BackTrace> traces;
    +  std::vector<BackTrace> traces;
       auto timer_driven = timer_scheduler_->getTraces();
       traces.insert(traces.end(), 
std::make_move_iterator(timer_driven.begin()), 
std::make_move_iterator(timer_driven.end()));
       auto event_driven = event_scheduler_->getTraces();
       traces.insert(traces.end(), 
std::make_move_iterator(event_driven.begin()), 
std::make_move_iterator(event_driven.end()));
    +  // repositories
    +  auto prov_repo_trace = provenance_repo_->getTraces();
    +  traces.emplace_back(std::move(prov_repo_trace));
    --- End diff --
    
    Just for the record as I have already approved the PR, this is fine as is. 
    
    push_back also supports move, so in such case there is no difference.
    
    The reason I prefer to avoid emplace in such cases is calling explicit 
ctors:
    ```
    class A
    {
      public:
      bool mb;
      explicit A(bool b): mb(b) {}
    };
    
    int main()
    {
      A* ap = new A(false);
      std::vector<A> vec;
      vec.emplace_back(ap); 
      std::cout << vec[0].mb; //prints true
    }
    ```


---

Reply via email to