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 bind from std::tr1 (the version that comes with Visual Studio).
You need to use the version of bind that is part of the Boost.Lambda library, i.e. boost::lambda::bind. Note that this is not the same as boost::bind.
You will need to #include <boost/lambda/bind.hpp>.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With