具有字符串成员的结构的集合与向量
set vs. vector of structs with string member
对于以下定义:
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;
编译成功。集合与向量的问题是什么?如何修复?感谢
相关文章:
- 如何将ampl中的集合表示为c++中的向量
- 如何写向量的无序向量集,即unordered_set<向量<向量<int>>集合?
- 从具有自定义排序的向量创建集合
- 在 c++ 中将集合转换为向量和向量转换为字符串时出现运行时异常
- 将字符串集合中的元素添加到字符串集合的向量中
- 如何在一对集合的向量中插入元素?vector<pair<int,set<string>>>
- 我可以在一行代码中将向量中与条件匹配的所有元素插入到集合中吗?
- 创建集合向量作为类成员会在 c++ 中给出错误
- 如何更有效地从向量或集合中擦除元素?
- 创建一个抽象类类型的集合,shared_ptr的抽象类向量
- 如何在 c++ 中将集合和数组合并到向量中
- 将索引存储在向量<集合<int>>与向量<向量中<int>>
- variadic宏可从未知参数集合中生成字符串向量
- 集合和向量.在C 中快速设置
- 将向量的元素添加到无序集合中
- 将集合转换为向量的向量
- 管理模板化派生类型的向量集合
- 集合<向量<int>>必须定义比较函数吗?
- 将指针传递到集合向量C++/cx
- 为什么当我尝试插入到集合向量中时,它会告诉我"vector subscript out of range"?