奇怪的"unable to match function definition"

weird "unable to match function definition"

本文关键字:match function definition to unable      更新时间:2023-10-16

我有

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++的下一个版本中。