Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/141.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 无法使用std::字符串和std::向量将值插入std::map_C++_C++11_Vector_Stl_Stdmap - Fatal编程技术网

C++ 无法使用std::字符串和std::向量将值插入std::map

C++ 无法使用std::字符串和std::向量将值插入std::map,c++,c++11,vector,stl,stdmap,C++,C++11,Vector,Stl,Stdmap,我将先发布我的代码,然后解释我的问题: typedef std::unique_ptr<SEntity> Entity; typedef std::vector<Entity> EntityVector; typedef std::map<std::string, EntityVector> EntityVectorMap; const void pushEntityVector(const std::string& key, const Entit

我将先发布我的代码,然后解释我的问题:

typedef std::unique_ptr<SEntity> Entity;
typedef std::vector<Entity> EntityVector;
typedef std::map<std::string, EntityVector> EntityVectorMap;

const void pushEntityVector(const std::string& key, const EntityVector& entity_vector)
{
    m_entity_vector_map[key] = entity_vector;
}
typedef标准::唯一的ptr实体;
typedef std::vector EntityVector;
typedef std::map EntityVectorMap;
const void pushEntityVector(const std::string&key,const EntityVector&entity_vector)
{
m_实体_向量_映射[键]=实体_向量;
}
正如您可能看到的,我正在尝试将EntityVector插入EntityVectorMap。但是,当我这样做时,我遇到了这个问题:

c:\program files (x86)\codeblocks\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_algobase.h|335|error: use of deleted function 'std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = SE::SEntity; _Dp = std::default_delete<SE::SEntity>]'|
c:\program files(x86)\codeblocks\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_algobase.h | 335 |错误:使用删除的函数'std::unique_ptr&std::unique_ptr::operator=(const std::unique_ptr&)[with _Tp=SE::SEntity;_Dp=std::default_delete]|

谢谢

m_entity_vector_map[key]=entity_vector
尝试复制
EntityVector
,从而尝试复制 本质上是复制
std::unique\u ptr
实体。您无法复制
std::unique\u ptr
(它将不再是唯一的)


您可能希望将
entity\u vector
移动到
m\u entity\u vector\u map
,但是您不能将
entity\u vector
作为常量引用传递到
pushEntityVector

m\u entity\u vector\u map[key]=entity\u vector
尝试复制
EntityVector
,从而尝试复制 本质上是复制
std::unique\u ptr
实体。您无法复制
std::unique\u ptr
(它将不再是唯一的)


您可能希望将
entity\u vector
移动到
m\u entity\u vector\u map
,但是您不能将
entity\u vector
作为常量引用传递到
pushEntityVector

m\u entity\u vector\u map[key]=entity\u vector
尝试复制
EntityVector
,从而尝试复制 本质上是复制
std::unique\u ptr
实体。您无法复制
std::unique\u ptr
(它将不再是唯一的)


您可能希望将
entity\u vector
移动到
m\u entity\u vector\u map
,但是您不能将
entity\u vector
作为常量引用传递到
pushEntityVector

m\u entity\u vector\u map[key]=entity\u vector
尝试复制
EntityVector
,从而尝试复制 本质上是复制
std::unique\u ptr
实体。您无法复制
std::unique\u ptr
(它将不再是唯一的)

您可能希望将
实体向量
移动到
m\u实体向量
映射中,但是您不能将
实体向量
作为常量引用传递到
pushEntityVector

中,因为您要插入的是
实体向量
的副本。这将不起作用,因为元素是
唯一的\u ptr
s,即不可复制,因此
向量本身是不可复制的。您正在插入
实体\u向量的副本。这将不起作用,因为元素是
唯一的\u ptr
s,即不可复制,因此
向量本身是不可复制的。您正在插入
实体\u向量的副本。这将不起作用,因为元素是
唯一的\u ptr
s,即不可复制,因此
向量本身是不可复制的。您正在插入
实体\u向量的副本。这将不起作用,因为元素是唯一的,即不可复制的,因此向量本身是不可复制的。