vector of map of unique_ptr not usable

Viewed 84

This simple code cannot be compiled in Visual Studio 2019 (latest update).

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

int main()
{
    std::vector<std::map<int, std::unique_ptr<int>>> v;
    v.resize(1);
}

The error is:

Severity    Code    Description Project File    Line    Suppression State
Error   C2280   'std::pair<const int,std::unique_ptr<int,std::default_delete<int>>>::pair(const std::pair<const int,std::unique_ptr<int,std::default_delete<int>>> &)': attempting to reference a deleted function  Test    C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\include\xmemory  671 

emplace_back() is also not working. Visual Studio 2015 and the latest gcc does not have a problem with it. Is the code wrong or the compiler? What can I do to make it compile?

0 Answers
Related