2013-04-21 16 views
13

Provo ad utilizzare la funzione emplace() per unorded_map e il compilatore dice che non esiste tale funzione.Funzionalità C++ 11 con MinGW

ho messo -std=c+11 e dice cc1plus.exe: error: unrecognized command line option '-std=c+11'

Posso in qualche modo utilizzare C++ 11 funzionalità con MinGW?

+9

Provare 'C++ 11' anziché' c + 11' –

+0

Oppure, o provare 'C++ 0x' –

+0

Nessuno dei due funziona (ho già C++ 0x ON) –

risposta

14

Dal 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.

Così, per gcc 4.3 tramite 4.6 uso -std = C++ 0x, per poi utilizzare la versione -std = C++ 11. Il supporto per la libreria per map::emplace è stato aggiunto in gcc 4.8

+0

stesso errore: 'class std :: unordered_map , dictionaryWord>' non ha un membro chiamato 'emplace' –

+0

Sono arrivato a credere che non posso usare C++ 11, o almeno tutto, con 4.6 . –

+1

È necessario gcc 4.8 per utilizzare 'map :: emplace', vedere ad es. [questa domanda] (http://stackoverflow.com/questions/14075128/mapemplace-with-a-custom-value-type) – TemplateRex