2013-04-21 15 views
13

Próbuję użyć funkcji emplace() dla nieuporządkowanej_mapy, a kompilator mówi, że taka funkcja nie istnieje.Funkcja C++ 11 z MinGW

kładę -std=c+11 i mówi cc1plus.exe: error: unrecognized command line option '-std=c+11'

można jakoś użyć C++ 11 funkcjonalność z MinGW?

+9

Wypróbuj 'C++ 11' zamiast' c + 11' –

+0

Albo albo spróbuj 'C++ 0x' –

+0

Żadnych prac (już mam C++ 0x WŁĄCZONY) –

Odpowiedz

14

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

tak na gcc 4.3 poprzez 4.6 użytku -std = C++ 0x, dla nowszej użytku -std = C++ 11. Obsługa biblioteki dla map::emplace została dodana w gcc 4.8

+0

ten sam błąd: 'class std :: unordered_map , dictionaryWord>' nie ma członka o nazwie 'emplace' –

+0

Doszedłem do przekonania, że ​​nie mogę użyć C++ 11, lub przynajmniej wszystkiego, z 4.6 . –

+1

Będziesz potrzebował gcc 4.8, aby użyć 'map :: emplace', zobacz np. [to pytanie] (http://stackoverflow.com/questions/14075128/mapemplace-with-a-custom-value-type) – TemplateRex