Stack overflow with unique_ptr linked list [closed]
问题 I've converted the following linked list struct struct node { node* next; int v; }; into a c++11 version - that is not using the pointers. struct node { unique_ptr<node> next; int v; }; Adding, removing elements and traversing works fine, however when I insert roughly 1mil elements, I get a stack overflow when when the destructor of the head node is called. I'm not sure what I'm doing wrong. { node n; ... add 10mill elements } <-- crash here 回答1: You are making nothing wrong here. When you