Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

std::map::emplace() missing - outdated libraries?

Tags:

c++

c++11

I'm trying to use the C++11 emplace() function of a map, but NetBeans says a map has no such function. Looking at the headers, it's "right" - there is no mention (on Fedora 16) of emplace(). Which is all well and good, you know... but I kinda wanna use emplace().

How do I go about enabling this functionality? I know for a fact that it's existed since March of last year, probably earlier. A thorough search shows that emplace() basically only exists on my system in the headers for lists and vectors. Since there hasn't been a major revision of C++ in almost a decade, I'm not having any luck finding documentation on what to do if the libraries are "wrong".

like image 641
DigitalMan Avatar asked Jan 23 '12 12:01

DigitalMan


Video Answer


2 Answers

If your implementation doesn't support something, you have two choices:

  • don't use the feature
  • use another implementation which supports what you need.

The fact that there is a new standard doesn't widen the choices. In fact, it reduces it as you'll have additional difficulties in finding an implementation which supports everything that you want for each one your targets.

Note that for pure library things, the other implementation could be one you make: compatibility wrappers have an increased appearance in transition time. But you have to pay attention to name clashes effects (visibility of compatibility wrappers may add ambiguities to the code when the feature appears at its standard place).

like image 118
AProgrammer Avatar answered Oct 08 '22 08:10

AProgrammer


GCC 4.7 does not support this as there were unresolved issues with the standard at the time. It is implemented in 4.8 and above. You will need -std=c++11

like image 32
Brice M. Dempsey Avatar answered Oct 08 '22 08:10

Brice M. Dempsey