I believe the situation is similar to the following:
#include <iostream>
#include <memory>
int main()
{
std::auto_ptr<int> a(new int(10));
std::auto_ptr<int> b = a.get() ? a : new int(10);
}
And here is Como's very enlightening error message:
"ComeauTest.c", line 7: error: operand types are incompatible ("std::auto_ptr<int>"
and "int *")
std::auto_ptr<int> b = a.get() ? a : new int(10);
^
, . NB! std::auto_ptr , , std::auto_ptr
:
std::auto_ptr<int> b = a.get() ? a : std::auto_ptr<int>(new int(10));