no matching function for call to 'TiXmlElement::TiXmlElement(std::_cxx11::string&)

349 Views Asked by At
    for (int i = g, x=0; i < counter - 1 && x < 99; i++,x++){
std::string point = std::to_string(i);
std::string pointx = std::to_string(point_vec[i].x);
std::string pointy= std::to_string(point_vec[i].y);

TiXmlElement* P = new TiXmlElement( point );
TiXmlText* X = new TiXmlText(pointx);
doc.LinkEndChild(X);
TiXmlText* Y = new TiXmlText(pointy);
doc.LinkEndChild(Y);
doc.LinkEndChild(P);
}

Above is my example code which I am trying to work on right now, my issue is that it tells me the following:

"error: no matching function for call to 'TiXmlElement::TiXmlElement(std::_cxx11::string&)" this is using wxwidgets on c++, the idea behind using tinyxml is to be able to store the arrays and reuse them after.

Solvved this : I had to go into tinyxml.h and add this at the top : #define TIXML_USE_STL

2

There are 2 best solutions below

2
Build Succeeded On BEST ANSWER

There are two constructors for string/char type as below:

TiXmlElement::TiXmlElement (const char * _value)

or

#ifdef TIXML_USE_STL
TiXmlElement::TiXmlElement( const std::string& _value ) 

So you have to define TIXML_USE_STL if you want to use std::string else use const char *

Refer the tinyxml.cpp

0
Eric On

As described, there is no matching function to TiXmlElement(std::_cxx11::string&) which as I understand correctly is some string class from c11 standarisation. In this case it will be exactly point string. Try to check if there is a way of using strings that are meant for TiXmlElement as obviously, as the error is saying, you're providing an instance of wrong class std::_cxx11::string&