Well.. @myself: Learning never stops. :)
Your constructor is not explicit and therefore a way to implicitly convert a MYSQL_RES*
into as auto_mysqlres
. This is what gcc does here. It converts the MYSQL_RES*
into a auto_mysqlres
and then tries to call the copy constructor. This is required here.
§ 8.5 [dcl.init] / 14
The initialization that occurs in the form
[...] is called copy-initialization.
You copy-inititalize your object.
§ 8.5 [dcl.init] / 16
[... If the initialization] is copy-initialization where the cv-unqualified version of the source type is the same class as, or a derived class of, the class of the destination, constructors are considered. [...]
Otherwise (i.e., for the remaining copy-initialization cases), user-defined conversion sequences that can convert from the source type to the destination type or (when a conversion function is used) to a derived class thereof are enumerated as described in 13.3.1.4, and the best one is chosen through overload resolution.
In your case MYSQL_RES*
is not the same class as, or a derived class of the destination class (auto_mysqlres
) so a conversion is required since the constructor isn't considered.
You'll either
have to do direct initialization
auto_mysqlres result(return_pointer_to_mysql_res());
or provide a (move) copy constructor.
PS: Wasn't quite aware of where the cv-unqualified version of the source type is the same class as, or a derived class of, the class of the destination
.