2013-04-21 8 views
13

Tôi cố gắng sử dụng chức năng emplace() cho unordered_map và trình biên dịch nói rằng không có chức năng nào tồn tại.Chức năng C++ 11 với MinGW

tôi đặt -std=c+11 và nó nói cc1plus.exe: error: unrecognized command line option '-std=c+11'

Tôi có thể bằng cách nào đó sử dụng chức năng C++ 11 với mingw?

+9

Hãy thử 'C++ 11' thay vì' c + 11' –

+0

Hoặc là, hoặc thử 'C++ 0x' –

+0

Không hoạt động (i allready have C++ 0x ON) –

Trả lời

14

Từ 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.

Vì vậy, đối với gcc 4.3 qua 4.6 sử dụng -std = C++ 0x, cho phiên bản sau này sử dụng -std = C++ 11. Hỗ trợ thư viện cho map::emplace đã được thêm vào gcc 4.8

+0

cùng một lỗi: 'class std :: unordered_map , dictionaryWord>' không có thành viên có tên 'emplace' –

+0

Tôi đã tin rằng tôi không thể sử dụng C++ 11, hoặc ít nhất là tất cả, với 4.6 . –

+1

Bạn sẽ cần gcc 4.8 để sử dụng 'map :: emplace', xem ví dụ: [câu hỏi này] (http://stackoverflow.com/questions/14075128/mapemplace-with-a-custom-value-type) – TemplateRex