In libstdC ++, the definitions of stoi , stol , etc., as well as the functions to_string are protected by the condition
#if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \ && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
I had a failure on one platform before (namely, Termux on Android), as a result, to_string not available even with g ++ 6.1 and the C ++ 14 standard. In this case, I just did
#define _GLIBCXX_USE_C99 1
before incorporating anything, and voilà, suddenly functions existed. (You should put this first or even on the command line, and not just before turning on <string> , because another header may include <string> first, and then its included guards will keep it from viewing your macro. )
I have not investigated why this macro was not installed in the first place. Obviously, this is troubling if you want your code to really work (in my case, I'm not really, but FWIW had no problems.)
You should check if _GLIBCXX_USE_C99 defined or _GLIBCXX_USE_C99 defined (what could be the case with MinGW?)
source share