为什么在将unique_ptr返回到模板类对象的函数定义中出错?

这很好用:

template <typename key_t>
class BST{
    struct node{
        node(const key_t mKey) : key(mKey){}

        key_t key;
        std::unique_ptr<node> left;
        std::unique_ptr<node> right;
    };

    //stuff

    //this function definition works fine here
    std::unique_ptr<node>& _find_next_successor(std::unique_ptr<node> &curr){
        if(curr->left == nullptr)
        return curr;

        return _find_next_successor(curr->left);
    }


};

但是,当我尝试在类之外实现_find_next_successor时,出现错误:

template <typename key_t>
class BST{
    struct node{
        node(const key_t mKey) : key(mKey){}

        key_t key;
        std::unique_ptr<node> left;
        std::unique_ptr<node> right;
    };

    //stuff

    //definition
    std::unique_ptr<node>& _find_next_successor(std::unique_ptr<node> &);

};

//implementation, I get error by the compiler
template <typename key_t>
std::unique_ptr<BST<key_t>::node> &
BST<key_t>::_find_next_successor(std::unique_ptr<node> &curr){
    if(curr->left == nullptr)
        return curr;

    return _find_next_successor(curr->left);
}
C:\ Users \ m \ Documents \ TreeNode20.cpp:65:33:错误:``模板类std :: unique_ptr''的模板参数列表中参数1处的类型/值不匹配    std :: unique_ptr :: node> BST :: _ find_next_successor(std :: unique_ptr&curr){                                    ^      C:\ Users \ m \ Documents \ TreeNode20.cpp:65:33:错误:预期为类型,得到了'BST :: node'   C:\ Users \ m \ Documents \ TreeNode20.cpp:65:33:错误:模板参数2无效   C:\ Users \ m \ Documents \ TreeNode20.cpp:65:35:错误:'int BST :: _ find_next_successor(std :: unique_ptr :: node>&)'的原型与类'BST'中的任何内容都不匹配    std :: unique_ptr :: node> BST :: _ find_next_successor(std :: unique_ptr&curr){                                      ^   C:\ Users \ marco \ Documents \ TreeNode20.cpp:22:25:错误:候选者是:std :: unique_ptr :: node>&BST :: _ find_next_successor(std :: unique_ptr :: node>&)     std :: unique_ptr&_find_next_successor(std :: unique_ptr&);                            ^

编译结果...

  • 错误:5
  • 警告:0
  • 编译时间:0.70s