Trouble after iPlug updating. "no suitable user-defined conversion from to exists"

Hi there!
I use the next kind of construction in my plugin

auto Midi_Action = [this, pGraphics](IControl* pCaller) {this->Midi_ActionClicked(pCaller); };

But after updating the iPlug2 I got lots of errors in my project in VS2019. The compiler said:

Error (active) E0312 no suitable user-defined conversion from "type" to "std::function" exists my-app my.cpp 174

and so on. All cases when I tried to capture this in a lambda function was underlined as an error.

Then I have rolled back iPlug2 update to one from February and my project started to work correctly.

I’m not sure what happened but trying to update iPlug2 to the latest version have the same results - my project doesn’t compiling in that case.

It looks I’ve hurried up. The errors E0312 is still here but the project can be compiled. It can be I have had other errors with updated iPlug2 but I didn’t recognise them

I have revised the project one more time with iPlug2 69f309fd497b9b18cd3dbe6280a73d5815bbce5c [69f309f] (from March, 1st, 2021, 22:36:51) - there is no errors after rebuild. So errors come after iPlug2 updating to the newer version

it’s not clear that this is an iPlug2 problem, if you can narrow it down please make a github issue

1 Like

try capturing like this:

auto FunctionName([&, pGraphics](IControl *pCaller)
{
// you can call member functions here without using "this"
}
1 Like

Thank you! It didn’t help but I know now that the trouble isn’t connected to capturing this in a lambda

Now, when I’ve changed this to &, I have errors like this:

Error	C2664	'void iplug::igraphics::IGraphics::ForControlInGroup(const char *,std::function<void (iplug::igraphics::IControl *)>)': cannot convert argument 2 from 'my::ProcessSysEx::<lambda_c824d55620e9fc3c8f6d97799d092177>' to 'std::function<void (iplug::igraphics::IControl *)>'

this lambda is

  this->pGraphics->ForControlInGroup(Tuning, [&](IControl& Control)
      {
        const char* ControlType = typeid(Control).name();
        if (!(strcmp(ControlType, "class TuningTabControl")))
        {
          TuningTabControl* c = static_cast<TuningTabControl*>(&Control);
          c->As<TuningTabControl>()->SetLabelStr(PresetList.GetCurrentPresetCombineName().c_str());

        }
      });

The troubles disappeare when I change the folders IPlug and IGraphics to the previous versions (from September, 22, 2020)

Are you sure you didn’t mean to type (IControl* Control) instead of (IControl& Control) in the lambda function arguments? The error log seems to be complaining about the signature of the function (referred to as “argument 2”).

1 Like

Yep, the signature has changed

1 Like

All IControl lamdas now look like

[](IControl* pControl) { … }

Before some used a reference not a pointer

1 Like

Thank you very much! I’ve corrected some code and now it works correct with the last iPlug2 version

2 Likes