Why my VS2010 can\'t compile this code:
#include
#include
int main()
{
std::vector vec;
std::bind(&std::
You should be more specific why this doesn't seem to work for you.
#include
#include
#include
int main(int argc, char* argv[]) {
std::vector vec;
std::tr1::bind(&std::vector::push_back, std::tr1::ref(vec), 1)();
std::cout << "vec.size = " << vec.size() << std::endl;
std::cout << "vec[0] = " << vec[0] << std::endl;
return 0;
}
$ gcc -o test -lstdc++ test.cpp && ./test
vec.size = 1
vec[0] = 1
Update: Luc Danton is right, the issue here is the overloaded push_back
. See question Are there boost::bind issues with VS2010 ?. Also, note that the issue is not limited to push_back
, see Visual Studio 2010 and boost::bind.