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

问题描述 投票:0回答:1

我正在使用带有 C/C++ 扩展的 VS Code for C++(

vscode-cpptools
),发现它不会对依赖于外部模板的模板参数的模板内模板中的某些内容提供建议。

这是一个例子:

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.
    }
};

为什么当我打字时

return_ptr()->

智能感知没有建议

do_st()

有什么办法可以实现这一点吗?还是intellisense不支持这个?

c++ templates visual-studio-code intellisense
1个回答
5
投票

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

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

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

© www.soinside.com 2019 - 2024. All rights reserved.