Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Make sure that</p> <pre><code>TiXmlDocument getDocument () { return this-&gt;_document; } </code></pre> <p>Will not deep copy its contained TiXmlElement's. Otherwise you return a temporary, use that in the constructor to set the root node, which then will be destructed already. I haven't looked in its API, but just be aware of such pitfalls. </p> <p>The reason for the ambiguous call is because:</p> <p>There are three overloads of <code>FirstChildElement</code> taking one argument:</p> <pre><code>const TiXmlElement * FirstChildElement (const char *value) const // :1 const TiXmlElement * FirstChildElement (const std::string &amp;_value) const // :2 TiXmlElement * FirstChildElement (const std::string &amp;_value) // :3 </code></pre> <p>You access the TiXmlElement through <code>TiXmlElement&amp;</code> (using a <code>TiXmlElement*</code> pointer). But the version taking a <code>const char*</code> has an implicit object parameter of <code>TiXmlElement const&amp;</code>. That is, a qualification conversion is required to make the call work. For the other versions taking a <code>std::string const&amp;</code>, there are conversions required too:</p> <pre><code>&lt;implied obj param&gt; &lt;implicit obj param&gt; &lt;arg1&gt; &lt;param1&gt; TiXmlElement&amp; TiXmlElement const&amp; char const* char const* // :1 TiXmlElement&amp; TiXmlElement const&amp; char const* std::string const&amp; // :2 TiXmlElement&amp; TiXmlElement&amp; char const* std::string const&amp; // :3 </code></pre> <p>There is an ambiguity between the first and the third overload. An easy fix is to do</p> <pre><code>this-&gt;setDialogsElement( this-&gt;getRootElement()-&gt;FirstChildElement(std::string("dialogs"))); </code></pre> <p>Instead, which will call the last version. Another fix is to const_cast:</p> <pre><code>this-&gt;setDialogsElement( const_cast&lt;TiXmlElement const*&gt;(this-&gt;getRootElement())-&gt; FirstChildElement("dialogs")); </code></pre> <p>Which will call the first version. As for why it only happens in DEBUG... I remember that TiXML has an option to disable the use of the STL. Maybe in release mode you disabled it (and thus the overloads taking <code>std::string</code>), but in debug mode you forgot?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload