0

I am writing a lightweight class to deal with csv format files. One of the functions is sum which is getting the sum of a specific column. It receives a numeric type as parameter and returns the sum of that type. So I write it in template style. I did it like this:

#define IS_NUMERIC_VALUE (  std::is_same<T,int>::value || std::is_same<T,long>::value || std::is_same<T,double>::value || std::is_same<T,float>::value || std::is_same<T,size_t>::value )
template < class T, class = typename std::enable_if< IS_NUMERIC_VALUE >::type > 
int sum(T& get_sum);

template < class T, class > 
int sum(T& get_sum)
{
    int iRet {1};
    //doing sth here
    return iRet;
}

It works well but when I was trying to move the implementation part to a .cpp file, I got an error of undefined symbol xxx. I can't put it in one file because I have many other similar ones. What is the problem?

Holt
  • 36,600
  • 7
  • 92
  • 139
Jacob
  • 1
  • 1

0 Answers0