#include <string>
#include "boost/lexical_cast.hpp"
using namespace std;
// class ~ typename = same thingΠαράδειγμα χρήσης:
template <class T>
string to_string(const T& arg) {
try {
return boost::lexical_cast<string>(arg);
}
catch(boost::bad_lexical_cast& e) {
return "";
}
}
float float_nr=31212.434;
string float_str=to_string(float_nr);
// float_str = "31212.43"

Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου