No matching constructor for initialization of 'ScopedPointer<juce::XmlElement>'

Hello,

Juce novice here. I am trying to build a code example and I have solved most of the errors, however I can’t fathom how to get around this error:

No matching constructor for initialization of 'ScopedPointer<juce::XmlElement>'

This is the code section it refers to.

// This getXmlFromBinary() helper function retrieves our XML from the binary blob..
    ScopedPointer<XmlElement> xmlState (getXmlFromBinary (data, sizeInBytes));

Sorry I don’t know how to format a code excerpt on this forum.

It sounds like the return type of getXmlFromBinary has changed since the code example was written. Instead of ScopedPointer, try using std::unique_ptr.

JUCE’s ScopedPointer class has been deprecated for a few years now. In new code, std::unique_ptr should always be preferred over ScopedPointer.

1 Like

Adding to this, using auto is often a good alternative:

auto xmlState = getXmlFromBinary (data, sizeInBytes);

N.B. to format code have three backticks on a single line before and after your code ```

1 Like

Thank you. Solved by reuk’s method.

Thank you. Formatting fixed.