Was ist los mit dieser Initialisierung von unique_ptr?
Kann mir jemand sagen, was mit der folgenden Initialisierung von unique_ptr nicht stimmt?
int main()
{
unique_ptr<int> py(nullptr);
py = new int;
....
}
g ++ -O2 xxx.cc -lm -o xxx -std = c ++ 11 sagt:
error: no match for ‘operator=’ (operand types are ‘std::unique_ptr<int>’ and ‘int*’)
py = new int;
^
Tu
unique_ptr<int> px(new int);
works ganz gut.