我有一些编译问题在使用g ++ -std = c ++ 0x进行编译时将类型T的元素推回到向量.
这是一个最小的例子:
#include <vector>
using namespace std;
class A {
public:
A() { }
A& operator=(A &orig) {
return *this;
}
};
int main(int argc, char **argv) {
A a;
vector<A> b;
A c = a; // This is fine
b.push_back(a); // This is not, but only when compiling with -std=c++0x!
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它使用g ++ -Wall -pedantic编译得很好,但是在使用g ++ -Wall -pedantic -std = c ++ 0x进行编译时会出现此错误:
In file included from /usr/include/c++/4.4/vector:69,
from min.cpp:1:
/usr/include/c++/4.4/bits/vector.tcc: …Run Code Online (Sandbox Code Playgroud)