错误C2064: term不计算为一个带1个参数/使用模板的函数
error C2064: term does not evaluate to a function taking 1 arguments / using a template
嗨,我得到这个错误信息时,试图编译这个:
template<typename T>
std::shared_ptr<T> sptr(T* ptr)
{
return std::shared_ptr<T>(ptr, &extension::IDeleteable::destroy);
}
costructorA(const Logger& _logger):logger(sptr(_logger.clone())) //here the error using sptr()
{}
logger is type: std::shared_ptr<Logger> logger;
class Logger
=
class GMRISK_FCUL_API Logger : public IDeleteable{
public:
virtual ~Logger() {}
virtual void destroy() const =0;
};
class IDeleateable
:
class IDeleteable
{
public:
virtual void destroy() const =0;
template<typename T>
static inline void destroy(T* value)
{
value->destroy();
}
};
完整的错误:
C:Program Files (x86)Microsoft Visual Studio 11.0VCincludememory(725): error C2064: term does not evaluate to a function taking 1 arguments
C:Program Files (x86)Microsoft Visual Studio 11.0VCincludememory(494) : see reference to function template instantiation 'void std::shared_ptr<_Ty>::_Resetp<_Ux,_Dx>(_Ux *,_Dx)' being compiled
with
[
_Ty=gmrisk::fcul::Logger,
_Ux=gmrisk::fcul::Logger,
_Dx=void (__thiscall extension::IDeleteable::* )(void) const
]
fcul_api.cpp(34) : see reference to function template instantiation 'std::shared_ptr<_Ty>::shared_ptr<T,void(__thiscall extension::IDeleteable::* )(void) const>(_Ux *,_Dx)' being compiled
with
[
_Ty=gmrisk::fcul::Logger,
T=gmrisk::fcul::Logger,
_Ux=gmrisk::fcul::Logger,
_Dx=void (__thiscall extension::IDeleteable::* )(void) const
]
你知道是什么产生的吗?
PD:此处没有包含命名空间
要获取指向静态成员函数模板的指针,需要显式地实例化它:
return std::shared_ptr<T>(ptr, &extension::IDeleteable::destroy<T>);
^^^
相关文章:
- 模板-模板参数推导:三个不同的编译器三种不同的行为
- 在不传递参数数量且只有3个点的情况下,如何使用变差函数
- 带有多个独立参数的C++For循环
- 表达式 SFINAE:如何根据类型是否包含具有一个或多个参数的函数来选择模板版本
- 具有多个转换的模板参数推导
- 具有两个间接寻址运算符 (C++) 的函数参数的用途
- 如何将可变参数模板转换为多个单个模板?(C++竞争编程调试模板)
- 如何允许模板参数中的类类型,仅当它有两个基类时
- c++ 构造函数 将 1 个字符串参数转换为 3 个属性
- 运算符重载:"operator+"必须采用零个或一个参数
- C++部分概念 id:显式模板规范顺序/第一个参数的特殊状态的原因是什么?
- 为什么 c++11 std::lock 和 std::scoped_lock 至少需要 2 个参数?
- 具有多个参数的模板化类专用化,其中一个模板参数是模板本身
- 我应该如何在没有变量的情况下将相同的参数传递给 CMAKE 中的多个目标?
- C++如果两个模板函数都与参数列表匹配,将调用哪个模板
- 如何实现具有多个平台__FILE__和__LINE__信息的 C/C++ 可变参数日志记录宏?
- 如何从两个不同的函数传递参数
- 为什么C CHAR数据类型3D数组通过参数第一个括号为空白
- 什么时候使用size_t作为模板函数的参数是个坏主意
- 警告:正在传递第1个参数(共个)..从不带强制转换的整数生成指针