是
struct A
{
std::unique_ptr<A> a;
};
标准允许吗?我不认为它适用于像 std::set
这样的容器类型,但是关于 unique_ptr
有什么特别吗?
最佳答案
是的,这是明确允许的。 C++14 (n4140) 20.8.1/5:
... The template parameter
T
ofunique_ptr
may be an incomplete type.
std::shared_ptr
和 std::weak_ptr
也允许使用类似的措辞。
关于c++ - std::unique_ptr 结构成员到结构类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31410352/