I have some functions that don't belong to any class. So right now, they're defined in my program.cpp. Specifically, a simple
std::string to_string(double const & value){
std::stringstream ss;
ss << value;
return ss.str();
}
I can use them in my classes when I declare std::string to_string(double const &);
. But I can't get that to work with templates, i.e. with
template <typename T>
std::string to_string(T const & value){
std::stringstream ss;
ss << value;
return ss.str();
}
In whatever way I declare it, I always end up with "undefined reference to" errors. Any way to do that? The way c++ forces bookkeeping on you makes me sad :(