I have a class that is not a templated class, I need to add a function to this class that is a template function. The problem is that I call a function in the class that requires a string as the parameter, so I need to make a specialized version of this template so I can call this function only if the parameter is a const char* or make a conditional check inside the function to only make a call to the function if the parameter is a const char* but that does not seem to work either. Any help would be appreciated!
template<class myType> __declspec(nothrow)
std::string GetStrVal(int row, int col, myType default) {
try {
CheckColumnType(col, String);
}
catch(DatatableException e){
return default;
}
return this->m_rows[row][col];
}
template<class myType>
std::string GetStrVal(int row, const char* col, myType default) {
unsigned int columnIndex = this->GetColumnIndex(col);
return GetStrVal(row,columnIndex, default);
}
GetColumnIndex() only takes a const char*.
You don’t need to specialize anything; you can just provide an overload or two: