如果我的代码: -Resharper是否以硬编码的方式识别std :: make_unique?
class B; //some B.h has definition of B
std::make_unique<B>();
ReSharper的会警告我说,我应该包括B.h
。 (正确)
类型 'B' 是不完整的
但是,如果我试图模仿std::unique_ptr<T>
代码,并把它里面Test.h
: -
Test.h
//inside class Test
template<class _Ty,
class... _Types> inline
typename std::enable_if<!std::is_array<_Ty>::value,
std::unique_ptr<_Ty> >::type test2(_Types&&... _Args)
{ // make a unique_ptr
return (std::unique_ptr<_Ty>(new _Ty(std::forward<_Types>(_Args)...)));
}
Test.cpp的
#include "Test.h"
//inside some function
test2<B>();
我不会得到任何警告。 (但它是不可编译,因为B是不完整的。)
问题
是否ReSharper的硬编码各地检查
std::make_unique
?如果不是,如何在一定程度上使得ReSharper的正确建议代码? (应包括
B.h
)
在实际使用,我想创造一些自定义的智能指针+池,
我想整形器正确建议#include
在用户的文件。
它也出现在std::make_shared
。
编辑: -
正如伊戈尔·艾哈迈托夫提到,它是硬编码的,反正是有,我可以线索ReSharper的?例如: -
//Hey, Resharper, the user must include full definition of "T".
// Resharper, forward declaration is not enough for "T".
template<class T> T* f(){
return new T();
}
谢谢!虽然有点令人失望,但我可以理解实现这个功能的难度。 .....顺便说一下,有什么方法可以提示Resharper吗? (我编辑过这个问题。) – javaLover
目前没有办法做到这一点。自然的方法是有一个特殊的属性,但它看起来像属性不能应用于C++中的模板参数。我提交了https://youtrack.jetbrains.com/issue/RSCPP-19172,我们会看看我们是否可以想出一些方法来做到这一点。 –
我有关于Resharper C++自动完成功能的另一个问题。不确定Resharper可以做到这一点。如果你能看一看,我将不胜感激。 http://stackoverflow.com/questions/43164856/autocompletion-of-parameter-list-static-fields-without-typing-a-classname – javaLover