以下函数无法编译:
std::unique_ptr<int> foo()
{
int* answer = new int(42);
return answer;
}
std::unique_ptr<int> bar()
{
return new int(42);
}
我觉得这有点不方便。为什么要让std::unique_ptr<T>(T*)
成为显式的呢?
shared_ptr
是显式的(explicit)。 - jxhunique_ptr
吗?这对我来说没有意义,因为整个重点是你不能复制它。 - cha0site