奇怪的"unable to match function definition"
weird "unable to match function definition"
我有
class ObjectController
{
public:
...
template<template<class> class Action, class T>
Action<T> * createAction(typename Action<T>::CommandFunction cf, T * t)
{
return new Action<T>(cf, t);
}
...
};
一切都很好。。。但我习惯于在我的类中只有声明,在其他文件中有定义。。。(*.inl表示模板)。。。但是当我把这些代码移到ObjectController类之外时,如下所示:
class ObjectController
{
public:
...
template<template<class> class Action, class T>
Action<T> * createAction(typename Action<T>::CommandFunction cf, T * t);
...
};
template<template<class> class Action, class T>
Action<T> * ObjectController::createAction(typename Action<T>::CommandFunction cf, T * t)
{
return new Action<T>(cf, t);
}
我得到:
unable to match function definition to an existing declaration definition
'Action<T> *gear::core::ObjectController::createAction(Action<T>::CommandFunction,T *)'
existing declarations
'Action<T> *gear::core::ObjectController::createAction(Action<T>::CommandFunction,T *)'
我该如何解决?
编辑当我从KennyTM中获取确切的代码(请参阅注释)并将其粘贴到我的VS2010中时,我会得到同样的错误。。。有人能证实吗?
Visual Studio 2005中存在一个错误,它阻止某些"概述"的模板函数正确编译。
这里有可用的修补程序。http://support.microsoft.com/kb/930198
这是一个错误。我已将其提交给Microsoft
https://connect.microsoft.com/VisualStudio/feedback/details/724362/unable-to-match-function-definition
该修复程序应显示在Visual C++的下一个版本中。
相关文章:
- "error: no matching function for call to"构造函数错误
- 调用专用模板时出错"no matching function for call to [...]"
- 库函数需要一个 std::function<void(void)>,如何传入类函数?
- Confusion: decltype vs std::function
- 为什么 std::function 可以作为 std::not2 的参数?
- 'max'匹配'std::function<const int &(const int &, const int &)>'无过载
- 传递给std::function template的template参数究竟代表什么
- 将带有unique_ptr的可变 lambda 传递给 const&std::function
- 绑定派生类方法C++从实例范围之外的分隔 std::function 变量调用
- "no matching function for call to 'Vector::Vector'"错误
- 如何在向量中删除 std::function<void()>?
- 不断"Attempting to reference a deleted function"
- 将函数包装器转换为 std::function
- 类型擦除的std::function与虚拟函数调用的开销
- C++ std::function 对于类 exept 的所有实例都是空的(只有 Visual2019 编译器问题)
- 如果模板没有可变参数,则 Lambda 被推导出为 std::function
- 我在 ifstream input_file(文件名)行中收到错误"no matching function to call";
- 模板规范获取'Ambiguous call to overloaded function'
- MSVC:带函数的"error C2244: unable to match function definition to an existing declaration"是指专用模板类的类型别名
- 奇怪的"unable to match function definition"