我想了解为什么代码
enum
{
SETA_ELT1,
SETA_ELT2,
SETA_ELT3,
};
enum
{
SETB_ELT1,
SETB_ELT2,
SETB_ELT3,
};
#define MAPPINGTYPE std::map<unsigned int, unsigned int>
MAPPINGTYPE::value_type bijection_table[] = //<---- line 68 raising the error
{
MAPPINGTYPE::value_type(SETA_ELT1, SETB_ELT1),
MAPPINGTYPE::value_type(SETA_ELT2, SETB_ELT2),
MAPPINGTYPE::value_type(SETA_ELT3, SETB_ELT3),
};
const MAPPINGTYPE bijectionMap(bijection_table, bijection_table+3);
无法在Visual Studio 10上编译错误
2>c:\Program Files (x86)\${MVCDIR}\VC\include\utility(246):
2>error C2664: 'std::forward' : cannot convert parameter 1 from '' to '&'
2> ..\myfile.cpp(68) : see reference to function template instantiation
2>'std::pair<_Ty1,_Ty2>::pair<,>(_Other1 &&,_Other2 &&)' being compiled
2> with
2> [
2> _Ty1=const unsigned int,
2> _Ty2=unsigned int,
2> _Other1=,
2> _Other2=
2> ]
我需要显式地将值SETB_ELTX
强制转换为unsigned int
才能成功编译。