Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++11 functionality with MinGW

I try to use emplace() function for an unordered_map and compiler says that no such function exists.

I put -std=c+11 and it says cc1plus.exe: error: unrecognized command line option '-std=c+11'

Can i somehow use C++11 functionality with mingw?

like image 984
pdrak Avatar asked Apr 21 '13 20:04

pdrak


1 Answers

From the 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.

So, for gcc 4.3 through 4.6 use -std=c++0x, for later version use -std=c++11. Library support for map::emplace was added in gcc 4.8

like image 168
TemplateRex Avatar answered Oct 04 '22 03:10

TemplateRex