我在尝试将一对插入地图时遇到了一个常量问题。编译器错误是:
c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(2089) : see reference to function template instantiation 'std::pair<_Ty1,_Ty2> &std::pair<_Ty1,_Ty2>::operator =(const std::pair<_Ty1,_Ty2> &)' being compiled
1> with
1> [
1> _Ty1=const Assets::AssetId,
1> _Ty2=std::shared_ptr<Assets::Material>
1> ]
1> c:\fusionengine\meshgl.cpp(85) : see reference to class template instantiation 'std::pair<_Ty1,_Ty2>' being compiled
1> with
1> [
1> _Ty1=const Assets::AssetId,
1> _Ty2=std::shared_ptr<Assets::Material>
1> ]
导致错误的行是:
m_materials.insert( MaterialsMap::value_type(pMaterial->AssetId(), pMaterial) );
m_materials 贴图声明如下:
typedef std::map< Assets::AssetId, std::shared_ptr<Material> > MaterialsMap;
typedef std::pair< Assets::AssetId, std::shared_ptr<Material> > MtlPair;
MaterialsMap m_materials;
错误 1 错误 C2166: l-value 指定 const 对象 c:\program files (x86)\microsoft visual studio 11.0\vc\include\utility 114
谁能解释我如何解决这个问题?