I have a template function in .hpp
file:
class Wrapper {
public:
...
template <typename T>
void PutIntoStream(T &&input);
};
void Wrapper::PutIntoStream(T &&input) {/*implementation*/}
In my .cpp
file this function is specialized:
template<>
void Wrapper::PutIntoStream(const int &input)
{}
template<>
void Wrapper::PutIntoStream(const std::string &input)
{}
But then I'm trying to run specializations the template function is run:
int val{0};
std::string s{"Val"};
PutIntoStream(val); // template <typename T> void PutIntoStream(T &&input)
PutIntoStream(s); // is called in both cases
Can anyone tell me what's the problem and how to fix it?