-2

I did exactly what was written here: Easiest way to convert int to string in C++

But I get an error at the std of std::to_string

#include <iostream>
#include <string>

int main()
{

std::string s = std::to_string(42);

return 0;
}
Community
  • 1
  • 1
Goblet
  • 1
  • 1
  • Did you read the first comment under that answer? Specifically "`to_string` not a member of `std` fix: http://stackoverflow.com/questions/12975341/to-string-is-not-a-member-of-std-says-so-g " – Jonny Henly Feb 26 '16 at 04:09
  • @JonnyHenly That's not the error message he says he's getting. – Barmar Feb 26 '16 at 04:22
  • 2
    Possible duplicate of [std::to\_string - more than instance of overloaded function matches the argument list](http://stackoverflow.com/questions/10664699/stdto-string-more-than-instance-of-overloaded-function-matches-the-argument) – Barmar Feb 26 '16 at 04:24

1 Answers1

2

The error message you get can't be generated for a standard-conforming library implementation.

So, the best solution is to upgrade the compiler (presumably it's some years old Visual C++).

An alternative is to use an argument of type long, and hope that that's one of the existing overloads:

std::to_string( 42L )
Cheers and hth. - Alf
  • 142,714
  • 15
  • 209
  • 331