所以我有一个这样的结构:
struct node {
node_type type;
StaticTokensContainer token_sc;
std::unique_ptr<node> left; // here
std::unique_ptr<node> right; // and here
};
Run Code Online (Sandbox Code Playgroud)
当我尝试编写一个递归函数将 a 转换node为字符串以进行打印时,如下所示:
std::string node_to_string(node n) {
return "<other members converted to strings>" + node_to_string(*(n.left));
}
Run Code Online (Sandbox Code Playgroud)
它给了我:function "node::node(const node &)" (declared implicitly) cannot be referenced -- it is a deleted function
我不明白为什么会出现这个错误,当我(*n)尝试将 n 作为 传递时std::unique_ptr<node>,我没有遇到任何问题,所以我不明白为什么*(n.left)不允许这样做。