int x = fromString(\"test\") :could not deduce template argument for \'ValueType\'
int x = fromString(\"test\")
int x = fromString(\"test\") : works
C++ doesn't do type inference on the return value. I.e., the fact that it is being assigned to an int isn't used in template parameter deduction.
(Removed edit, since someone else presented the overloaded cast solution already.)