I've got a class with constructors defined like this:
LambdaJSONVisitor(); LambdaJSONVisitor(boost::function<void (const Value &)> f); LambdaJSONVisitor(boost::function<void (const Object &)> f); LambdaJSONVisitor(boost::function<void (const KeyValuePair &)> f); LambdaJSONVisitor(boost::function<void (const Array &)> f); and I'm trying to construct an object like this:
LambdaJSONVisitor setNodeIDVisitor([&](const JSONAPI::Value &val) -> void { ... }); When I try to compile it, I'm getting the following compiler error:
4>netmodel\CNetworkAlarmBuilder.cpp(60): error C2668: 'JSONAPI::LambdaJSONVisitor::LambdaJSONVisitor' : ambiguous call to overloaded function 4> C:\workspace\client\projects\JSONParser\API/LambdaJSONVisitor.h(21): could be 'JSONAPI::LambdaJSONVisitor::LambdaJSONVisitor(boost::function<Signature>)' 4> with 4> [ 4> Signature=void (const JSONAPI::Array &) 4> ] 4> C:\workspace\client\projects\JSONParser\API/LambdaJSONVisitor.h(20): or 'JSONAPI::LambdaJSONVisitor::LambdaJSONVisitor(boost::function<Signature>)' 4> with 4> [ 4> Signature=void (const JSONAPI::KeyValuePair &) 4> ] 4> C:\workspace\client\projects\JSONParser\API/LambdaJSONVisitor.h(19): or 'JSONAPI::LambdaJSONVisitor::LambdaJSONVisitor(boost::function<Signature>)' 4> with 4> [ 4> Signature=void (const JSONAPI::Object &) 4> ] 4> C:\workspace\client\projects\JSONParser\API/LambdaJSONVisitor.h(18): or 'JSONAPI::LambdaJSONVisitor::LambdaJSONVisitor(boost::function<Signature>)' 4> with 4> [ 4> Signature=void (const JSONAPI::Value &) 4> ] 4> while trying to match the argument list '(`anonymous-namespace'::<lambda1>)' is it possible to pass a lambda as a parameter to an overridden constructor like this? If so, what am I doing wrong and how should I change the code to make it work? I'm using Visual Studio 2010.
Thanks