Witam chciałem sobie napisac mała funkcje konwertujacą liczby do string, z użyciem szablonów i zmodziłem coś takiego:
template <typename N>
inline const N& convertFromString(const std::string& s)
{
std::istringstream i(s);
N& x;
if (i >> x)
return x;
return 0;
}
Ale przy próbie kompilacji z kodem :
double x =0.0f;
std::string str = "10.0f";
x = convertFromString(str);
kompilator ładnie mnie informuje:
error: no matching function for call to `convertFromString(std::string&)'
I nie moge obejsc tego, możę mi ktoś wyjąsnić gdzie jest błąd lub czego brakuje?.
Z góry dzięki.