जी ++ 4.7.2 को लागू करता है std::set::emplace
के रूप में सी ++ 11 स्टैंडर्ड द्वारा परिभाषित और here दस्तावेज?std ::, सेट कोई भी सदस्य क़ायम करना है
मैं निम्नलिखित छोटे से परीक्षण का मामला लिखा है:
#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"));
}
G के अंतर्गत ++ 4.7.2, इस संकलन करने में विफल रहता है:
[[email protected] 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’
इसके अलावा IDEOne के तहत संकलित करने के लिए विफल रहता है, लेकिन यह के अंतर्गत संकलित करता है एमएसवीसी 2012 अपडेट 1.