我想在Irrlicht遊戲中使用Irrnet網絡庫。爲什麼我的程序在調用std ::隊列的front()時停止?
源代碼使用Linux套接字,我試圖移植它的Windows替換它使用Windows'Winsock2的代碼。
庫編譯成功,但是當我嘗試運行Quake示例時,它崩潰了。我找到程序停止的那一行,但我無法弄清楚如何解決這個問題。
程序停止在該函數的第二個電話在GetNextItem
class NetworkType {
public :
NetworkType();
~NetworkType();
template<class T>
void getNextItem(irr::core::vector3d<T>& data);
private:
typedef std::queue<std::string> Container;
Container items;
};
template<class T>
void NetworkType::getNextItem(irr::core::vector3d<T>& data) {
T X, Y, Z;
std::istringstream item(items.front());
// the program does not get here the second time it calls this function
items.pop();
item >> X;
item >> Y;
item >> Z;
data = irr::core::vector3d<T>(X, Y, Z);
}
,準確地在該行
std::istringstream item(items.front());
誰能告訴我,爲什麼程序停止它得到了第二次到這條線?
這裏是link的完整源代碼
這似乎沒有與遊戲開發相關,可能更適合StackOverflow;我已經提出了遷移考慮的問題。 –
Assert(!items.empty());你應該總是編碼你的假設。 – dcousens