vendredi 1 avril 2016

Compiler error with vector of deque of unique_ptr

The following code fails to compile on gcc 5.3 with compiler error complaining that the copy constructor of the unique_ptr is somehow invoked. Can someone explain why this happens?

#include <iostream>
#include <memory>
#include <queue>

using Foo = std::deque<std::unique_ptr<int>>;                                   


void foo() {                                                                    
  std::vector<Foo> a;                                                           
  a.emplace_back();   // this fails to compile                                                             
}  

Aucun commentaire:

Enregistrer un commentaire