Lately I read this post:
How do I use boost.lambda with boost.thread to get the thread's return value?
I tried to implement the answer and it went fairly well except I get an error that I can’t solve.
My code is this:
falcon::Mesh* falcon::ResourceManager::GetMesh(const std::string& id)
{
Mesh* meshPtr;
boost::thread meshLoadThread(boost::lambda::var(meshPtr) = bind(&MeshManager::LoadMesh, MeshManager::GetInstance(), id));
meshLoadThread.join();
return meshPtr;
}
But when I try to compile, I get the following error
error C2440: '=' : cannot convert from
'const std::tr1::_Bind<_Result_type,_Ret,_BindN>'
to 'falcon::Mesh *'
I know it should work normally because in the example it works too!
Anyone got any suggestions?
You are using
bindfromstd::tr1(the version that comes with Visual Studio).You need to use the version of
bindthat is part of theBoost.Lambdalibrary, i.e.boost::lambda::bind. Note that this is not the same asboost::bind.You will need to
#include <boost/lambda/bind.hpp>.