#include <iostream>
#include <sstream>
#include <string>
using namespace std;
template <class T>
inline string to_string(const T &v)
{
ostringstream os;
os << v;
return os.str();
}
int main()
{
string str1 = to_string(5);
cout << str1 << endl;
string str2 = to_string(1.2);
cout << str2 << endl;
return 0;
}
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
template <class T>
inline T from_string(const string &str) {
istringstream is(str);
T v;
is >> v;
return v;
}
int main() {
int v1 = from_string<int>("5");
cout << v1 << endl;
double v2 = from_string<double>("1.2");
cout << v2 << endl;
return 0;
}