Min*_*Ant 3 c++ string queue reference data-structures
我有这个有趣的情况.
我有一堆结构字符串.
struct foo
{
string mStringName;
}
vector<foo> mFoos;
Run Code Online (Sandbox Code Playgroud)
我也有一个字符串引用队列
queue<string&> mStringQueue;
Run Code Online (Sandbox Code Playgroud)
最后,我有一个接受const字符串的函数&
void Bar(const string&);
Run Code Online (Sandbox Code Playgroud)
继承人的情况.
//...in some loop
currentFoo = mFoos[index];
// Queue up the string name.
mStringQueue.push(currentFoo.mStringName);
//...Later on, go through our queue and pass each one to the function.
for (int queueIndex = 0; queueIndex < mStringQueue.size(); queueIndex++)
{
Bar(mStringQueue.front());
mStringQueue.pop();
}
Run Code Online (Sandbox Code Playgroud)
这给了我以下编译错误:
错误C2664: '的std ::队列<_Ty> ::推':无法从 '字符串' 到 '串(&)' 转换参数1
我是definitley无法绕过字符串引用和诸如此类的东西,所以任何帮助都将非常感激