No matching constructor for initialization of 'juce::AudioProcessorValueTreeState::ButtonAttachment'

Hello! For several days now I can’t understand why this error occurs, everything seems to be correct. Maybe someone has come across or knows what could be the matter?

“No matching constructor for initialization of ‘juce::AudioProcessorValueTreeState::ButtonAttachment’”

in this code:

TrigButtons::TrigButtons (SamplerpluginAudioProcessor& p)  : processor(p)
    for(int i=0; i<numOfButtons; i++)
        auto newButton = new ToggleButton {  };
        std::unique_ptr<juce::AudioProcessorValueTreeState::ButtonAttachment> btnAttch
            std::make_unique<juce::AudioProcessorValueTreeState::ButtonAttachment> (p.getApvts(), std::to_string(i), buttons[i])

I would really appreciate any help! Thanks for answers

The second parameter of ButtonAttachment is of type juce::String not std::string. Use juce::String(i) and this will be resolved. (I don’t know what the type of your buttons field is, so you might also need to dereference the result of the operator [int] with *buttons[i]).

The semantics are a hole different question though. The second parameter is supposed to be the parameter id you want to attach inside the APVTS. In this case, either the parameter is really named 0 which wouldn’t be that good since it is not descriptive, or the name is not 0 and you should check how you can pass the name. Its the same name when you create the parameter layout for your APVTS.

1 Like

Thank you very much, but the problem was not in juce::String, I understood what was the matter - “new ToggleButton” returned a pointer, just had to put * in the right place. I need to learn C++ better :slight_smile: