red-squiggle non-existing dependent name (e.g. C<T>::nonMember ) as error

只愿长相守 提交于 2019-12-25 01:00:30

问题


How to make Resharper syntax-highlight non-exist dependent name (e.g. member field) as error?

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.

I believe there must be such a feature,
because Resharper can already recognize all fields of Test1<> correctly (shown in the following image).


回答1:


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

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.



来源:https://stackoverflow.com/questions/54900697/red-squiggle-non-existing-dependent-name-e-g-ctnonmember-as-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!