Resharper 是否以硬编码方式识别 std::make_unique?

Does Resharper recognize std::make_unique in a hard-code way?

如果我编码:-

class B;  //some B.h has definition of B
std::make_unique<B>();  

Resharper 会警告我应该包含 B.h。 (正确)

Type 'B' is incomplete

但是,如果我尝试模仿 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不完整所以无法编译。)

问题

std::make_shared 也会发生这种情况。

编辑:-

正如 Igor Akhmetov 提到的那样,它是硬编码的,无论如何我可以为 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();
}

您是对的,std::make_uniquestd::make_shared 的完整性和重载解析检查是硬编码的。对于像 std::make_unique 这样的函数,R++ 无法从函数的签名中推断出需要用作模板参数的 class 的定义。但是,std::make_uniquestd::make_unique 非常常见,因此专门针对它们引入了额外的检查。

也就是说,用作模板参数的 classes 的定义通常是转发引用的模板函数参数所必需的。在这种情况下,我们可能会考虑显示警告(但不是错误)。