Does g++ 4.7.2 implement std::set::emplace
, as defined by the C++11 Standard and documented here?
I have written the following little test case:
#include <set> #include <string> struct Foo { std::string mBar; bool operator<(const Foo& rhs) const { return mBar < rhs.mBar; } Foo(const std::string bar) : mBar(bar) {}; }; typedef std::set<Foo> Foos; int main() { Foos foos; foos.emplace(std::string("Hello")); }
Under G++ 4.7.2, this fails to compile:
[john.dibling@somewhere hacks]$ g++ -o main.o -std=c++0x -c main.cpp main.cpp: In function ‘int main()’: main.cpp:19:10: error: ‘Foos’ has no member named ‘emplace’
Also fails to compile under IDEOne, however it does compile under MSVC 2012 Update 1.
It is not implemented in gcc 4.7.2.
There is some explanation:
Just to clarify a bit: this wasn't an oversight. We had the nasty problem in the Draft C++0x Standard with std::pair, which essentially made impossible adding the emplace_* members to std::map, std::multimap, etc, without breaking existing user code. Thus we waited on that, until things got clarified in this whole area. Now it's actually possible to work on those facilities.
Your code compiles nicely with gcc 4.8.0, see LWS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With