Why does gcc require a copy constructor to invoke an implicit conversion constructor?
class X { public: X(int q) {} ~X() { std::cout << "~X()" << std::endl; } X(const X&) = delete; }; X x = 1;
More interesting here, even if I write a copy constructor, it is not called. The destructor is called only once, so the following code
class X { public: X(int q) {} ~X() { std::cout << "~X()" << std::endl; } X(const X&) { std::cout << "copy ctor" << std::endl; } }; int main() { X x = 1; }
Fingerprints ~X()
This is mistake? Is there any workaround?
The gcc version on my locaL machine is 4.6.3, this also works on a different version of gcc (online)
http://ideone.com/ustDRj
c ++ gcc constructor copy-constructor implicit-conversion
ax
source share