Lambas in G4GenericMessenger::DeclareMethod

I’m starting now to make large use of G4GenericMessenger in my application. I was wondering if there is any way to give a lambda function to G4GenericMessenger::DeclareMethod, or maybe to create a G4AnyMethod instance with a lambda? I’m thinking about something like this:

std::unique_ptr<G4GenericMessenger> fMessenger(this, "/app/",
    "Commands for controlling the application");

// ...

fMessenger->DeclareMethod("CommandName", 
    [](G4String str) { G4cout << str << G4endl; },
    "Command to write a string to the standard output");