# Calling reset() on a unique\_ptr\<XmlElement\> no longer compiles in VS2019?

**URL:** <https://forum.juce.com/t/calling-reset-on-a-unique-ptr-xmlelement-no-longer-compiles-in-vs2019/37317>\
**Category:** General JUCE discussion\
**Created:** [January 25, 2020, 1:48pm UTC](https://forum.juce.com/t/calling-reset-on-a-unique-ptr-xmlelement-no-longer-compiles-in-vs2019/37317 "2020-01-25T13:48:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomto66](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/tomto66/32/4916_2.png) [@tomto66](https://forum.juce.com/u/tomto66)\
**Post date:** [January 25, 2020, 1:48pm UTC](https://forum.juce.com/t/calling-reset-on-a-unique-ptr-xmlelement-no-longer-compiles-in-vs2019/37317/1 "2020-01-25T13:48:17Z")

</div>

Hi! I just upgraded to the last Juce version, and I have stuff that no longer compiles in VS2019. Can’t seem to figure out why. Here’s what I have:

I have a variable called ‘model’ that contains bits and pieces of my data model, declared with a smart pointer as follows

```auto
std::unique_ptr<XmlElement> model;

```

And now the following 2 lines no longer compile:

```auto
model.reset(AudioProcessor::getXmlFromBinary(data, sizeInBytes));
...
model.reset(XmlDocument::parse(f));

```

Both parse() and getXmlFromBinary() return a pointer to an XmlElement - model.reset() does not seem to accept this here and produces following error:

```auto

Error	C2664	'void std::unique_ptr<juce::XmlElement,std::default_delete<_Ty>>::reset(juce::XmlElement *) noexcept': cannot convert argument 1 from 'std::unique_ptr<juce::XmlElement,std::default_delete<_Ty>>' to 'juce::XmlElement *'

```

Strangely, if I do something like the following, the compiler happily accepts that:

```auto
model.reset(new XmlElement("Test"));

```

Anybody a clue what I’m doing wrong, and why this behavior ? Any clues would be appreciated!

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [January 25, 2020, 2:02pm UTC](https://forum.juce.com/t/calling-reset-on-a-unique-ptr-xmlelement-no-longer-compiles-in-vs2019/37317/2 "2020-01-25T14:02:43Z")

</div>

reset takes a raw pointer, but parse and getXmlFromBinary return unique\_ptr now

---

<div class="post-metadata">

**Author:** ![tomto66](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/tomto66/32/4916_2.png) [@tomto66](https://forum.juce.com/u/tomto66)\
**Post date:** [January 25, 2020, 2:05pm UTC](https://forum.juce.com/t/calling-reset-on-a-unique-ptr-xmlelement-no-longer-compiles-in-vs2019/37317/3 "2020-01-25T14:05:05Z")

</div>

Tx Reuk. Damn. Any clue how I should deal with this now then?

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [January 25, 2020, 2:11pm UTC](https://forum.juce.com/t/calling-reset-on-a-unique-ptr-xmlelement-no-longer-compiles-in-vs2019/37317/4 "2020-01-25T14:11:08Z")

</div>

You can assign a unique\_ptr just normal. It uses move semantic, so the pointer you are assigning from becomes nullptr.

```auto
std::unique_ptr<XmlElement> model;
model = AudioProcessor::getXmlFromBinary(data, sizeInBytes);
model = XmlDocument::parse(f);
model = std::make_unique<XmlElement>("Test");

```

should work.

---

<div class="post-metadata">

**Author:** ![tomto66](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/tomto66/32/4916_2.png) [@tomto66](https://forum.juce.com/u/tomto66)\
**Post date:** [January 25, 2020, 2:22pm UTC](https://forum.juce.com/t/calling-reset-on-a-unique-ptr-xmlelement-no-longer-compiles-in-vs2019/37317/5 "2020-01-25T14:22:20Z")

</div>

Tx @daniel - I was WAY overthinking this \< slapHead /\> 🙂
