¿Qué tiene de malo esta inicialización de unique_ptr?
¿Alguien puede decirme qué hay de malo en la siguiente inicialización de unique_ptr?
int main()
{
unique_ptr<int> py(nullptr);
py = new int;
....
}
g ++ -O2 xxx.cc -lm -o xxx -std = c ++ 11 dice:
error: no match for ‘operator=’ (operand types are ‘std::unique_ptr<int>’ and ‘int*’)
py = new int;
^
Haciendo
unique_ptr<int> px(new int);
funciona bien