![](/img/trans.png)
[英]Why can't I use istream_view and std::accumulate to sum up my input?
[英]Why can't I input an integer from the istream? *Error on starred input operators*
istream& operator>>(istream& is, State& s){
uint16_t first;
int second;
char delim;
is **>>** first >> delim >> second >> delim; //For player in Room.
for(GameObject* i : GameObject::GameObjects){
is **>>** first >> delim >> second >> delim;
s.containerObjects.insert(pair<int, int>(first, second));
}
s.containerObjects.insert(pair<int, int>(first, second));
return is;
}
帶星號的輸入運算符從 clang 給我一個錯誤:'二進制表達式的操作數無效(std::istream 和 uint16_t)。
文件中的數據如下所示:
0:1|2:2|3:4|
誰能幫我理解為什么?
謝謝!
編輯:原始運算符用法:
file >> currentState;
錯誤消息:'二進制表達式的無效操作數(std::istream 和 uint16_t)說明了一切。 沒有為 uint16_t 類型定義 >> 運算符。 嘗試 >> 進入普通的 int 類型,然后 static_cast<unint16_t> 將值放入變量“first”中。
我沒有包含 iostream ......但是我仍然能夠使用 istream 和 ostream 與基本字符串,所以我猜這是一個內置的東西?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.