I am trying to obtains a boost::function to a new_ptr (with parameters) which can be stored in a hash table for later use. A kind of registrar of ids to constructors for modules to use. Below is the simplified problem :
#include <boost/lambda/bind.hpp>
#include <boost/lambda/construct.hpp>
#include <boost/function.hpp>
using namespace boost::lambda;
struct TestObject
{
TestObject(int p){}
};
void doStuff()
{
boost::function<TestObject*(int)> tf1 = bind(new_ptr<TestObject>(), _1);
}
The binding works by itself, but the syntax for boost::function must be off, because it gives me:
error C2664: 'TestObject::TestObject(int)' : cannot convert parameter 1 from 'boost::lambda::lambda_functor<T>' to 'int' BOOST\1.57.0\boost\lambda\construct.hpp 146 1
I've done this before with constructors that have no parameters (works great). I can't figure out exactly what's missing, or if I'm trying to do something impossible.
Compiling with boost v1.57.0 and msvc 2012 (v110).
Code compiles on standalone MSVC 2015
You may Upgrade your VS, reconfigure Visual Studio 2012 to MSVC 2015 or encapsulate your functions on a lib/dll compiled from command line.