Can somebody tell me, what is wrong with the following initialization of unique_ptr?
int main()
{
unique_ptr<int> py(nullptr);
py = new int;
....
}
g++ -O2 xxx.cc -lm -o xxx -std=c++11 says:
error: no match for ‘operator=’ (operand types are ‘std::unique_ptr<int>’ and ‘int*’)
py = new int;
^
Doing
unique_ptr<int> px(new int);
works just fine.