2013-04-21 86 views
13

我尝试使用emplace()功能的unordered_map和编译器说,没有这样的功能存在。C++ 11功能与MinGW

我把-std=c+11和它说cc1plus.exe: error: unrecognized command line option '-std=c+11'

我可以以某种方式使用C++ 11的功能与MinGW的?

+9

尝试'C++ 11'而不是'c + 11' – 2013-04-21 20:58:34

+0

要么,要么尝试'C++ 0x' – 2013-04-21 21:05:48

+0

既不能工作(我已经有C++ 0x ON ) – 2013-04-21 21:23:56

回答

14

GCC documentation

C++0x was the working name of a new ISO C++ standard, which was then released in 2011 as C++11 and introduces a host of new features into the standard C++ language and library. This project seeks to implement new C++11 features in GCC and to make it one of the first compilers to bring C++11 to C++ programmers.

C++11 features are available as part of the "mainline" GCC compiler in the trunk of GCC's Subversion repository and in GCC 4.3 and later. To enable C++0x support, add the command-line parameter -std=c++0x to your g++ command line. Or, to enable GNU extensions in addition to C++0x extensions, add -std=gnu++0x to your g++ command line. GCC 4.7 and later support -std=c++11 and -std=gnu++11 as well.

所以,对于GCC 4.3 4.6通过使用-std =的C++ 0x,供以后使用版本-std = C++ 11。库支持map::emplace被添加到gcc 4.8

+0

相同的错误:“类的std :: unordered_map <性病:: basic_string的,dictionaryWord>”没有名为“布设” – 2013-04-22 13:40:45

+0

构件我来相信我不能C++ 11,或至少所有的,使用具有4.6 。 – 2013-04-22 13:47:54

+1

你需要gcc 4.8才能使用'map :: emplace',参见[这个问题](http://stackoverflow.com/questions/14075128/mapemplace-with-a-custom-value-type) – TemplateRex 2013-04-22 14:45:23