Bind and overloaded operators in Visual Studio 2008

Hello everyone, This is my first post to this list so apologies in advance for all the rules I will be breaking. I have a problem using overloaded operators in Visual Studio 2008 SP1 (no feature pack installed) with Boost version 1.36.0. The following code works perfectly in Visual Studio 2005: ////////// #include <algorithm> #include <functional> #include <vector> struct Foo { Foo(unsigned int first, unsigned int second) : first_(first), second_(second){}; unsigned int first_; unsigned int second_; }; int main(int, char*) { std::vector<Foo> v(10, Foo(1, 2)); const unsigned int test = 1; std::find_if(v.begin(), v.end(), std::tr1::bind( std::equal_to<unsigned int>(), std::tr1::bind(&Foo::first_, std::tr1::placeholders::_1), test)); std::find_if(v.begin(), v.end(), std::tr1::bind( &Foo::first_, std::tr1::placeholders::_1 ) == test ); return 0; } ////////// The 2 find_if calls have the exact same behaviour. If I compile this with 2008, I get the following errors for the second find_if call: .\main.cpp(19) : error C2784: 'bool std::tr1::operator ==(std::tr1::_Unutterable,const std::tr1::function<_Fty> &)' : could not deduce template argument for 'const std::tr1::function<_Fty> &' from 'const unsigned int' C:\Program Files\Microsoft Visual Studio 9.0\VC\include\../include/functional(1100) : see declaration of 'std::tr1::operator ==' .\main.cpp(19) : error C2784: 'bool std::tr1::operator ==(const std::tr1::function<_Fty> &,std::tr1::_Unutterable)' : could not deduce template argument for 'const std::tr1::function<_Fty> &' from 'std::tr1::_Bind<_Ret,_BindN>' with [ _Ret=std::tr1::_Notforced, _BindN=std::tr1::_Bind1,std::tr1::_Ph<1>> ] C:\Program Files\Microsoft Visual Studio 9.0\VC\include\../include/functional(1094) : see declaration of 'std::tr1::operator ==' .\main.cpp(19) : error C2784: 'bool std::tr1::operator ==(const std::tr1::shared_ptr<_Ty> &,const std::tr1::shared_ptr<_Ty2> &)' : could not deduce template argument for 'const std::tr1::shared_ptr<_Ty> &' from 'std::tr1::_Bind<_Ret,_BindN>' with [ _Ret=std::tr1::_Notforced, _BindN=std::tr1::_Bind1,std::tr1::_Ph<1>> ] C:\Program Files\Microsoft Visual Studio 9.0\VC\include\../include/memory(1598) : see declaration of 'std::tr1::operator ==' .\main.cpp(19) : error C2676: binary '==' : 'std::tr1::_Bind<_Ret,_BindN>' does not define this operator or a conversion to a type acceptable to the predefined operator with [ _Ret=std::tr1::_Notforced, _BindN=std::tr1::_Bind1,std::tr1::_Ph<1>> ] I have honestly no idea what I should do to fix this. Mailing list and google searches turned up nothing so any help would be much appreciated. TIA, Ben ------------------------- Ben Swerts Software engineer ICOS Vision Systems NV -------------------------

In the case of VS2005, you're using boost::bind by way of boost::tr1. In the case of VS2008, you're using Dinkumware's std::tr1::bind. There is no feature pack for VS2008 SP1, only for VS2008 RTM, as SP1 comes with TR1. The bug you're seeing is in Dinkumware's bind, not boost's. Try using boost::bind explicitly and I suspect it will work fine.
participants (2)
-
Adam Merz
-
Benjamin Swerts