没有匹配“运算符”>>'在“本地”中
此函数阻止 Wagic:自制程序编译:
/home/white/Pandora/wagic-read-only/projects/mtg/src/GameOptions.cpp:1156: error: 与“operator>>”不匹配在 的 >>本地'
源(GameOptions.cpp):http:// /code.google.com/p/wagic/source/browse/trunk/projects/mtg/src/ GameOptions.cpp 来源(一般): http://code.google.com/p/wagic/source/browse/
(第 1142-1172 行)
bool GameOptionKeyBindings::read(string input)
{
istringstream iss(input);
vector<pair<LocalKeySym, JButton> > assoc;
while (iss.good())
{
stringstream s;
iss.get(*(s.rdbuf()), ',');
iss.get();
LocalKeySym local;
char sep;
u32 button;
s >> local >> sep >> button;
if (':' != sep)
return false;
assoc.push_back(make_pair(local, u32_to_button(button)));
}
if (assoc.empty())
return false;
JGE* j = JGE::GetInstance();
j->ClearBindings();
for (vector<pair<LocalKeySym, JButton> >::const_iterator it = assoc.begin(); it != assoc.end(); ++it)
j->BindKey(it->first, it->second);
return true;
}
我将如何重写它以使其能够编译?
This function is preventing Wagic: the homebrew from Compiling:
/home/white/Pandora/wagic-read-only/projects/mtg/src/GameOptions.cpp:1156: error: no match for ‘operator>>’ in ‘s >> local’
Source(GameOptions.cpp): http://code.google.com/p/wagic/source/browse/trunk/projects/mtg/src/ GameOptions.cpp
Source(General):
http://code.google.com/p/wagic/source/browse/
(Line 1142-1172)
bool GameOptionKeyBindings::read(string input)
{
istringstream iss(input);
vector<pair<LocalKeySym, JButton> > assoc;
while (iss.good())
{
stringstream s;
iss.get(*(s.rdbuf()), ',');
iss.get();
LocalKeySym local;
char sep;
u32 button;
s >> local >> sep >> button;
if (':' != sep)
return false;
assoc.push_back(make_pair(local, u32_to_button(button)));
}
if (assoc.empty())
return false;
JGE* j = JGE::GetInstance();
j->ClearBindings();
for (vector<pair<LocalKeySym, JButton> >::const_iterator it = assoc.begin(); it != assoc.end(); ++it)
j->BindKey(it->first, it->second);
return true;
}
How would I rewrite this to get it to compile?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
调用默认的
operator>>
,它不理解您的自定义类LocalKeySym
,因此您需要为您的重载Operator>>
自定义类LocalKeySym
。示例代码:
Calls the default
operator >>
which does not understand your custom classLocalKeySym
So You need to Overload theOperator >>
for your custom classLocalKeySym
.An sample code:
operator >>
仅针对内置类型定义,如int
、float
、char
、< code>double 等,可以使用指针输入地址。由于您的变量local
是自定义类型LocalKeySym
。您可能必须定义自己的运算符>>
。它应该类似于重载 istream 和 ostream 运算符。请参阅教程。
operator >>
is defined only for built-in types like,int
,float
,char
,double
etc. and it can input the address using pointers. Since your variablelocal
is of custom typeLocalKeySym
. you may have to define your ownoperator >>
.It should be similar to overloading istream and ostream operators. See the tutorial here.