Is there a way to disable copy elision in c++ compiler
问题 In c++98, the following program is expected to call the copy constructor. #include <iostream> using namespace std; class A { public: A() { cout << "default" ; } A(int i) { cout << "int" ; } A(const A& a) { cout << "copy"; } }; int main () { A a1; A a2(0); A a3 = 0; return 0; } That is evident if you declare the copy constructor explicit in above case (the compiler errors out). But I don't I see the output of copy constructor when it is not declared as explicit. I guess that is because of copy