有人可以解释这句话:
shared variables
x = 0, y = 0
Core 1 Core 2
x = 1; y = 1;
r1 = y; r2 = x;
Run Code Online (Sandbox Code Playgroud)
怎么可能有r1 == 0和r2 == 0x86处理器?
可能重复:是否
可以抛出具有私有拷贝构造函数的对象?
据我所知,当你把对象作为值时,应该创建副本.因此,如果存在,则应调用复制构造函数.如果copy ctor存在并且是私有的,那么这应该导致编译错误.这是代码示例
class Exception {
public:
Exception() {
cout << "Exception()" << endl;
}
~Exception() {
cout << "~Exception() " << endl;
}
private:
Exception(const Exception &c) {
cout << "Exception(c)" << endl;
}
};
Run Code Online (Sandbox Code Playgroud)
下一个代码应该导致编译错误.
try {
Exception local;
throw local;
} catch (...) {
}
Run Code Online (Sandbox Code Playgroud)
但是VS 2005和VS 2008都成功地编译了代码并调用私有ctor.我错了,这是非标准行为,是编译器中的错误吗?