本文介绍了红色波浪线不存在的依赖名称(例如 C&lt;T&gt;::nonMember )作为错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 如何使 Resharper 语法高亮显示不存在的依赖名称(例如成员字段)作为错误?How to make Resharper syntax-highlight non-exist dependent name (e.g. member field) as error?在下面的代码中,我希望 a.nonMember 有红色波浪线.In the below code, I expect a.nonMember to has red squiggle.template<class T>class Test1{ public: int member;};template<class T>void f(){ Test1<T> a; a.member=5; a.nonMember=8; //<-- expect red squiggle here}然而,没有这样的红色波浪线.However, there is no such red squiggle.我相信一定有这样的功能,因为 Resharper 已经可以正确识别 Test1 的所有字段(如下图所示).I believe there must be such a feature, because Resharper can already recognize all fields of Test1<> correctly (shown in the following image).推荐答案Resharper 没有错.它无法知道这样的成员不存在,因为该成员是依赖的,所以可能存在.Resharper is not wrong. It has no way to know such a member doesn't exist, because the member is dependent, and so could exist.template<>class Test1<int> { public: int nonMember;};当我们可以调用 f() 时,现在应该突出显示什么?专业化的可能性意味着对依赖名称进行此类诊断是难以处理的.What should be highlighted now when we can call f<int>()? The possibility of specializations means that making such diagnostics is intractable for dependent names. 这篇关于红色波浪线不存在的依赖名称(例如 C&lt;T&gt;::nonMember )作为错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-14 08:29