I am trying to get the following code to compile:
template <class T, typename std::enable_if<!std::is_fundamental<T>::value, int >::type = 0 >
class Calc
{
public:
int operator()( const T& v ) const {
return v.getValue();
}
};
template <class T, typename std::enable_if<std::is_fundamental<T>::value, int >::type = 0 >
class Calc : CalcBase <T>
{
};
On compilation I am getting the following error:
c.cpp:26: error: template parameter 'typename std::enable_if<(! std::is_fundamental::value), int>::type <anonymous>'
c.cpp:36: error: redeclared here as 'typename std::enable_if<std::is_fundamental::value, int>::type <anonymous>'
The intent here is to select the the version of Calc that overrides the base class function call operator if the passed template parameter is a class. If the passed parameter is a fundamental type, then we choose the version of Calc that does not override the base class functionality. Could you please help me understand how I can get this working?
Aucun commentaire:
Enregistrer un commentaire