为什么 Intellisense 不为使用外部模板参数的模板内部的模板提供建议?

noo*_*mer 4 c++ intellisense templates visual-studio-code

我正在使用带有 C/C++ 扩展 ( vscode-cpptools) 的 VS Code for C++,发现它没有对依赖于外部模板的模板参数的模板内模板中的某些内容提供建议。

这是一个例子:

template <typename T>
class B
{
public:
    void do_st()
    {
        std::cout << "do_st" << std::endl;
    };
};

template <typename T>
class A
{
public:
    std::shared_ptr<B<T>> return_ptr()
    {
        return std::make_shared<B<T>>();
    }
    void do_ss()
    {
        return_ptr()->do_st();
        // ^before I type "do_st()" here, "do_st" is not one of
        //  the suggestions, but I expected that it would be.
    }
};
Run Code Online (Sandbox Code Playgroud)

为什么当我打字时

return_ptr()->
Run Code Online (Sandbox Code Playgroud)

智能感知没有建议do_st()

有什么办法可以实现这一点吗?或者智能感知不支持这个?

sta*_*all 5

尽管在您展示的场景中,我认为静态分析应该能够解决这个问题,但它并不总是那么简单(C++ 是一种相当粗糙的语言,并且随着新的语言标准的增加,它的复杂性也随之增加)。

vscode-cpptools github 页面上有相关(尚未解决)的问题:

您可以通过点赞反应来提高这些问题票证的优先级,并订阅它们以获取有关任何更新的通知。