Reputation: 7834
I have
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);
}
...
};
and everything works just fine... But I am used to have only declarations in my classes and definitions in other file... (*.inl for templates)... But when I move this code outside the class ObjectController like this:
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);
}
I get:
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 *)'
How can I solve it?
edit when I take exact code from KennyTM (see comments) and paste it to my VS2010 I get the same error... Can somebody confirm it?
Upvotes: 0
Views: 378
Reputation: 7834
It is a bug. I have submitted it to Microsoft
The fix should show up in the next release of Visual C++.
Upvotes: 0
Reputation: 63883
There is a bug in Visual Studio 2005 that prevents certain "outlined" template functions from compiling correctly.
There is a hotfix available here. http://support.microsoft.com/kb/930198
Upvotes: 1