Reputation: 602
The following code, compiles fine MSVC, but when building GCC provides a lot of errors:
#define FORCE_INLINE inline
#define CREF(A) const A&
template <class F>
class RDOFunCalcStd: public RDOFunCalc
{
...
template <class T>
FORCE_INLINE T getParam(CREF(LPRDORuntime) pRuntime, ruint paramNumber);
template <>
FORCE_INLINE double getParam<double>(CREF(LPRDORuntime) pRuntime, ruint paramNumber)
{
return pRuntime->getFuncArgument(paramNumber).getDouble();
}
template <>
FORCE_INLINE int getParam<int>(CREF(LPRDORuntime) pRuntime, ruint paramNumber)
{
return pRuntime->getFuncArgument(paramNumber).getInt();
}
...
};
Errors list:
error: explicit specialization in non-namespace scope ‘class rdoRuntime::RDOFunCalcStd’
error: template-id ‘getParam’ in declaration of primary template
error: explicit specialization in non-namespace scope ‘class rdoRuntime::RDOFunCalcStd’
error: template-id ‘getParam’ in declaration of primary template
error: ‘int rdoRuntime::RDOFunCalcStd::getParam(const rdoRuntime::LPRDORuntime&, ruint)’ cannot be overloaded
error: with ‘double rdoRuntime::RDOFunCalcStd::getParam(const rdoRuntime::LPRDORuntime&, ruint)’
What should be done to solve the error?
Upvotes: 0
Views: 1347
Reputation: 24850
See this
It explained why. To be short, C++ does not support function template specialization.
Upvotes: 3