I understand how auto_ptr
works in C++03. It is based on this trick. The trick uses a user-defined conversion to steal the pointer from one object to another when code such as this auto_int p(auto_int(new int()));
is written. However, I've several questions in this regard.
- Why isn't the compiler-generated copy-ctor called?
- Why does the user-defined conversion take precedence over a compiler-generated copy-ctor?
- Is there a compiler-generated copy-ctor to begin with?
- If not, what language rule suppresses it?