24

g++ 4.7.2 はstd::set::emplace、C++11 標準で定義され、ここに文書化されているように実装されていますか?

次の小さなテスト ケースを作成しました。

#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 では、これはコンパイルに失敗します。

[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’

IDEOneでのコンパイルにも失敗しますが、MSVC 2012 Update 1 ではコンパイルできます。

4

2 に答える 2