dimanche 29 mars 2015

error: no matching function for call to ‘to_string(std::basic_string

Even though in a template I can have any type, the function to_string does not work on basic strings:


for example:



std::string str("my string");
my_class(str);


with this functor definition:



template<class valuetype>
void operator()(valuetype value)
{
...
private_string_field = std::to_string(value);


does not work. here is the error:



error: no matching function for call to ‘to_string(std::basic_string&)’



What is the best way to avoid it.


In advance, I request avoid linking to irrelevant questions just because of a few common keywords.


Aucun commentaire:

Enregistrer un commentaire