samedi 20 octobre 2018

How to use the insert function of a nested map with the key type unique_ptr?

I have a variable:

std::map<int, std::map<int, unique_ptr<int>>> var1;

When I use

var1.insert({ 1, {} });

The compiler says:

'std::pair<const _Kty,_Ty>::pair(const std::pair<const _Kty,_Ty> &)': attempting to reference a deleted function

But obviously I didn't copy any unique_ptr.

Use

var1.insert({ 1, {0, std::unique_ptr<int>()} });

results the same error.

How should I use the insert function with this kinds of std::map, please?

Thank you!

Aucun commentaire:

Enregistrer un commentaire