我对C++相当陌生,而且我很可能在我的脑海中,但事情就是这样。与Boost一起使用Winsock bind()调用时出现“无法推论出模板参数”错误
我正在使用一个相当大的Win32 C++项目,它使用Winsock进行网络通信。我正在尝试将一些线程管理转换为boost,但是一旦我添加了对boost库的引用,而不是,我在这行代码中遇到了大约30个错误:
bind(mLocalSocketFd, (struct sockaddr *) &localServerAddress, sizeof(localServerAddress));
这些错误包括像:
error C2602: 'std::tr1::_Result_of2<_Fty,_Farg0,_Farg1>::_Type' is not a member of a base class of 'std::tr1::_Result_of2<_Fty,_Farg0,_Farg1>'
error C2868: 'std::tr1::_Result_of2<_Fty,_Farg0,_Farg1>::_Type' : illegal syntax for using-declaration; expected qualified-name
error C2784: 'bool std::operator <(const std::vector<_Ty,_Ax> &,const std::vector<_Ty,_Ax> &)' : could not deduce template argument for 'const std::vector<_Ty,_Ax> &' from 'std::tr1::_Bind_fty<_Fty,_Ret,_BindN>'
error C2784: 'bool std::operator <(const std::vector<_Ty,_Ax> &,const std::vector<_Ty,_Ax> &)' : could not deduce template argument for 'const std::vector<_Ty,_Ax> &' from 'std::tr1::_Bind_fty<_Fty,_Ret,_BindN>'
我猜想,不知怎的,我已经成功地告诉这个特殊的文件(“NetServer.cpp”)使用绑定()的增压版本,但对于我的生活,我无法弄清楚发生了什么。我使用boost的唯一部分是boost/thread.hpp,并且我没有使用NetServer.cpp中的任何地方或者它链接到的头文件来进行任何命名空间。
任何有关我在做什么错的建议,或者如何解决它?这显然是一些愚蠢的新手,但我无法弄清楚。
我不是“使用命名空间增强;”我可以找到标题层次结构中的任何位置,这就是让我困惑的原因。我仍然不确定它为什么试图在该特定文件中使用boost命名空间。但我不知道::作为一个全局命名空间限定符。添加解决了这个问题。谢谢。 – 2010-03-17 16:03:58