stoi is not a member of std?

I am using code::blocks version 13.12 and tried to compile this code.
1
2
3
4
5
#include <string>
int main(){
    std::string s = "42";
    int i = std::stoi(s);
}

It give me an error saying that 'stoi' is not a member of std, though I am sure that it is, in C++11.
I have also enabled the C++11 in the compiler flag.
Googling this yielded some results saying that MinGW does not support stoi,to_string() and such string-numeric conversion functions. Is there any other compiler I can use which supports C++11 as much as MinGW?
I am using Windows 7 32bit.
P.S it runs fine on http://cpp.sh
Last edited on
You could use Visual Studio.
It's really good, but does not support C++11 as much as MinGW. Moreover, it looks horrible for C++ coding. Very less auto completion compared to Code blocks.
Latest versions of MinGW.
Visual Studio compilers.
MiiNiPaa, I didn't understand your post, can you elaborate a little bit?
Do you mean that latest versions of MinGW, fixed the stoi(),.. issues?

This 64-bit build of MinGW has std::stoi() http://nuwen.net/mingw.html
So I would guess that a current 32-bit build (GCC 4.9.1) would have it too.

For a standard C++ library implementation way better than what GNU offers:
Visual Studio Express 2013 (Desktop): http://www.microsoft.com/en-us/download/details.aspx?id=44914

With the LLVM toolchain for Visual Studio, http://llvm.org/builds/ we also get the best C++ compiler on Windows.

A workaround (assumes that std::strtol() is available):
http://www.cplusplus.com/forum/beginner/120836/#msg657958
Last edited on
I've never used Code Blocks but VS can auto complete pretty much anything that intellisense picks up. I'm using VS 2013 Professional so it may be different on different versions.
Last edited on
Yes. It works fine now. And fix to that problem was avaliable for a long time.
there some links to alternative MinGW builds
http://www.cplusplus.com/forum/beginner/149018/#msg780232

Alternatively you could try to build clang.

For a standard C++ library implementation way better than what GNU offers:
Visual Studio Express 2013 (Desktop): http://www.microsoft.com/en-us/download/details.aspx?id=44914

I heard that visual C++ does not support `constexpr` fully. And `initializer_list` too.

With the LLVM toolchain for Visual Studio, http://llvm.org/builds/ we also get the best C++ compiler on Windows.

Is LLVM a compiler like GCC?
Last edited on
initiaizer_list's are supported. constexpr however is not.
> I heard that visual C++ does not support `constexpr` fully. And `initializer_list` too.

The current version of the Microsoft compiler does not support constexpr
It has complete support for initializer lists.
For other C++11 features, see: http://msdn.microsoft.com/en-us/library/hh567368.aspx


> Is LLVM a compiler like GCC?

clang++ is the C++ compiler from LLVM. http://clang.llvm.org/
libc++ is their implementation of the standard C++ library (not available on Windows): http://libcxx.llvm.org/
> It has complete support for initializer lists.
VS2015 preview lists it as Partial:
NSDMIs and initializer lists were previously listed as Yes, but have been downgraded to Partial

http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx
It also has a partial constexpr implementation.

clang++ is the C++ compiler from LLVM. http://clang.llvm.org/
libc++ is their implementation of the standard C++ library (not available on Windows): http://libcxx.llvm.org/

That means I can't use it on windows? :O
> That means I can't use it on windows?

You can use the LLVM compiler (clang++) with the Microsoft library.

You would get a compiler that is somewhat better than than the GNU compiler, and a library that is a lot better than the GNU library.

You can use the LLVM compiler (clang++) with the Microsoft library.

You would get a compiler that is somewhat better than than the GNU compiler


Cool, thanks a lot.

So What I have to do is just install Visual studio express, and clang++?
Is there any tutorial for this?
Will using another compiler have any effect on the VS debugger?

 
and a library that is a lot better than the GNU library.


Why do you say it is better? It does not support C++11 as much as GCC.
VS has subpar support for core language features. Standard library is more or less complete (and it works better on Windows than libstdc++)
http://msdn.microsoft.com/en-us/library/hh567368.aspx
Scroll to Standard Library Features. Note that almost all defects were fixed in VS2012 and now as article states:
As for the C++11 Standard Library, we don't have a pretty comparison table of features, but Visual C++ in Visual Studio 2012 implemented it, with two exceptions. First, when a library feature depended on functionality that was missing in the compiler, it was either simulated—for example, simulated variadic templates for make_shared<T>()—or it wasn't implemented. (There were only a few cases—most notably, <initializer_list>—which are now fully implemented in Visual C++ in Visual Studio 2013.) With very few exceptions, C99 has been implemented in Visual C++ in Visual Studio 2013 and C++ wrapper headers provided.
Hmm, Ok. I am away from my desktop(Which has visual studio) right now. But I will check it again when I get home after some days. I will update the topic then. :)
> It does not support C++11 as much as GCC

GNU libstdc++ has truly vast expanses of non-conformance (on all platforms).

IMHO, while a lot of it can be tolerated, these are show-stoppers:

Non-conforming std::basic_string (suffers from the mad-cow disease).

Non-conforming std::list<> (not an allocator-aware container, O(N) size())

Virtually no support for localization (missing standard code conversion facets). On non-linux platforms, there are no locales either (other than the classic and default locales).

Broken C++11 thread-safety.
Ok, I got visual studio professional and Visual assist X trials, and I am not going to go back to code blocks again. Previously visual studio's syntax highlighting and all was not very good but visual assist made it a 10000X better then code blocks.

Anyway, I will use Visual C++ compiler even if it does not fully support C++11 right now. Thanks for the suggestions.

P.S it supports stoi as well :).
Last edited on
Topic archived. No new replies allowed.