std::stoi and std::to_string on MinGW

Jonathan Wakely jwakely.gcc@gmail.com
Sat Dec 20 02:29:00 GMT 2014


People keep hitting the problem that std::stoi and std::to_string are
not defined when using MinGW, because of the fix for
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37522

If the problem is only with vswprintf then couldn't we enable
everything except std::to_wstring?

That would solve the problem for most people, as std::to_string and
all the std::sto* functions would be defined, we'd only be missing
std::to_wstring which I never see anyone trying to use anyway.
-------------- next part --------------
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 7729384..6423c59 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -5240,8 +5240,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \
-     && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
+#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99)
 
 #include <ext/string_conversions.h>
 
@@ -5392,6 +5391,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   stold(const wstring& __str, size_t* __idx = 0)
   { return __gnu_cxx::__stoa(&std::wcstold, "stold", __str.c_str(), __idx); }
 
+#ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
   // DR 1261.
   inline wstring
   to_wstring(int __val)
@@ -5453,6 +5453,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
     return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
 					    L"%Lf", __val);
   }
+#endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
 #endif
 
 _GLIBCXX_END_NAMESPACE_CXX11


More information about the Libstdc++ mailing list