15年11个月前IP:未同步
281471
2楼
Re:错误 1214 error C2039: “_Type”: 不是“std::tr1::_Result_type2<__f
Thanks for reporting this issue. I've resolved it as By Design because the libraries are behaving correctly. Winsock's bind() is declared in the global namespace. <functional>'s bind() is declared in namespace std (I am skipping over some subtleties that are not relevant here). They coexist happily despite having the same name, because that's what namespaces are for.

However, when you say "using namespace std;", you make all of the names in namespace std available to unqualified name lookup. Therefore, both Winsock's bind() and <functional>'s bind() are considered during overload resolution, and because <functional>'s bind() is a template, it will usually win, but fail to compile later. That's why the compiler error here is so horrible.

To fix this, call ::bind() when you want Winsock's bind(), and std::bind() if you ever want <functional>'s bind(). When you call ::bind(), you're asking the compiler to look in the global namespace only.
评论
文号 / 281471

实习会员
名片发私信
学术分 0
总主题 1 帖总回复 8 楼拥有证书:笔友
注册于 2011/02/11 21:14:46最后登录 2018/01/10 01:10:39
主体类型:个人
所属领域:无
认证方式:邮箱
IP归属地:0

个人简介

暂未填写
笔记
{{note.content}}
{{n.user.username}}
{{fromNow(n.toc)}} {{n.status === noteStatus.disabled ? "已屏蔽" : ""}} {{n.status === noteStatus.unknown ? "正在审核" : ""}} {{n.status === noteStatus.deleted ? '已删除' : ''}}
  • 编辑
  • 删除
  • {{n.status === 'disabled' ? "解除屏蔽" : "屏蔽" }}
我也是有底线的