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
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.
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.
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. :)
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).
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.