对于以下定义:
struct Operand
{
Operand(std::string opName,bool isInput,bool isOutput,bool isReg) : m_opName(opName),m_isInput(isInput),m_isOutput(isOutput),m_isReg(isReg) {}
std::string m_opName;
bool m_isInput;
bool m_isOutput;
bool m_isReg;
};
typedef std::set<Operand> SensitivityList;
SensitivityList m_sensitivityList;
应执行以下循环:
for (SensitivityList::iterator it = m_sensitivityList.begin();it != m_sensitivityList.end();++it)
{
AddToInterfaceList(it->m_opName,portList,portList,false);
}
的签名AddToInterfaceList
是:
static void AddToInterfaceList(std::string& data,std::string& interfaceList32Bit,std::string& interfaceList1Bit);
上面的代码编译失败,错误如下:
'AddToInterfaceList' : cannot convert parameter 1 from 'const std::string' to 'std::string &'
如果我重新定义SensitivityList
为:
typedef std::vector<Operand> SensitivityList;
编译成功。set vs.vector有什么问题?以及如何解决?谢谢