#include <map>
#include <string>
#include <memory>
#include <vector>

using namespace std;

// Used in the example
struct Resource {};

int main(int argc, char** argv) {
  // I was able to get the following map running fine
  // int -> { string -> unique_ptr }
  map<int, map<string, unique_ptr<Resource>>> data;

  map<string, unique_ptr<Resource>> toBeInserted;
  toBeInserted["key"] = unique_ptr<Resource>(new Resource);
  // data[1] = toBeInserted; // error
  data[1] = std::move(toBeInserted); // ok


  // But the issue happens when it's a vector of unique_ptrs
  // int -> { string -> { [unique_ptr] } }
  map<int, map<string, vector<unique_ptr<Resource>>>> otherData;

  vector<unique_ptr<Resource>> list;
  list.push_back(unique_ptr<Resource>(new Resource));
  list.push_back(unique_ptr<Resource>(new Resource));

  map<string, vector<unique_ptr<Resource>>> _toBeInserted;
  _toBeInserted["key"] = std::move(list); // ok

  // But I cant insert _toBeInserted back to the original map.
  // The compilation errors are all related to the unique_ptr 
  otherData[1] = std::move(_toBeInserted); // Can't do this 
}