C ++ 11 vector <struct>上的emplace_back?
考虑以下程序: #include <string> #include <vector> using namespace std; struct T { int a; double b; string c; }; vector<T> V; int main() { V.emplace_back(42, 3.14, "foo"); } 它不起作用: $ g++ -std=gnu++11 ./test.cpp In file included from /usr/include/c++/4.7/x86_64-linux-gnu/bits/c++allocator.h:34:0, from /usr/include/c++/4.7/bits/allocator.h:48, from /usr/include/c++/4.7/string:43, from ./test.cpp:1: /usr/include/c++/4.7/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& …