Reputation: 1614
I wanted to use an stl hashmap, and as among other things i found c++ doesn't have it, but c++0x does - so as someone who is not up to date - is c++0x safe to use? (Is it already fully tested and can be counted on to be relatively bug free?). If so - it seems like there are a lot of newer versions (c++11) - should i use them, or maybe they are still not reliable enough. Actually anyway when i try to use something from the new interface, my linux compiler tells me that i have to include c++0x - so i guess my compiler isn't up to date enoug
Upvotes: 0
Views: 275
Reputation: 137870
C++0x was the working title of C++11.
Look up your compiler version in the c++11 tag info page to learn about its support for new features.
Long story short: GCC is well ahead of the pack but still doesn't have 100% of the features. Some things such as user-defined literals are not yet supported by any compiler. (Edit: I'm not sure, but I think some features of regular expressions and the atomic memory model fall into this category.) Essential features such as rvalue references are widely complete.
std::unordered_map
was introduced by C++03 TR1, and is supported by all C++11 implementations and also all modern C++03 implementations through their TR1 libraries, even without C++11 language support. Under TR1, the template is called std::tr1::unordered_map
, and you might have to take some platform-specific step to enable TR1, such as adding some tr1/
subdirectory to the include file search paths.
Upvotes: 6
Reputation: 76316
There is no C++0x. That was a working name for what has finally become C++11 on 12 August 2011.
The standard contains many parts that were drafted separately and compilers started supporting them individually even before the standard was finalized, but on the other hand some parts are not yet supported at all. So you need to check whether your compiler supports the features you want to use.
Now the particular case of std::unordered_map
, it was first standardized in C++ TR1, but originates long before that in boost. Most compilers that don't support C++11 do support TR1, so std::tr1::unordered_map
will be there and you can always take it from boost for those that don't.
As for gcc, the error is that you need to enable C++11. That is done by simply adding -std=c++0x
option to the compiler command-line. This is done so that you don't accidentally use C++11 feature in code you still care about portability to C++03 compilers.
Upvotes: 1
Reputation: 3436
It is supposed to be safe for non safety-critical applications. I think that there is no safety-critical compiler with C++0x support yet.
But, for desktop applications, you should have no problems with that. But note that just a few compilers support C++0x (afak gcc 4.6+ and VC 2010), and they don't support all the functionalities. It is important that you read the compiler specifications to check what they support and what they don't.
I would prefer to wait a newer release of these compilers to use it in commercial apps.
Upvotes: 1
Reputation: 4519
Yes, it should be safe. But - like you've already seen - only part of C++11 standard is implemented in various compilators. Try to get the newest gcc, it implements majority of C++11 features: http://gcc.gnu.org/projects/cxx0x.html
Upvotes: 2