#include <iostream>
struct int_wrapper
{
int i;
int_wrapper(int i = 0) : i(i) {}
};
struct A
{
int_wrapper i;
int_wrapper j;
A(int_wrapper i = 0, int_wrapper j = 0) : i(i), j(j) {}
};
int main()
{
A a;
a = {3};
// error: no match for ‘operator=’ (operand types are ‘A’ and ‘int’)
// a = 3;
std::cout << a.i.i << std::endl;
return 0;
}
I know that isn't allowed more than one user-conversion when doing an implicit conversion, but, why with a brace-init-list the double user-conversion works?
Aucun commentaire:
Enregistrer un commentaire