template<typename T>
string int_to_str(T v, const Fmt &f)
{
- unsigned size=max(f.get_width(), max(f.get_precision(), sizeof(T)*8+3));
+ unsigned size=max(f.get_width(), max<unsigned>(f.get_precision(), sizeof(T)*8+3));
char *buf=new char[size];
string result(int_to_str(v, f, buf+size), buf+size);
delete[] buf;
bool str_to_bool(const string &s)
{
+ if(s.empty())
+ throw LexicalError("Empty input in boolean conversion");
+
if(s=="1" || s=="true" || s=="yes" || s=="on")
return true;
else if(s=="0" || s=="false" || s=="no" || s=="off")
- return true;
+ return false;
+
throw LexicalError("Invalid input in boolean conversion");
}
}
// Apply rounding
- w+=5.0l/pow(10.0l, digits);
+ w+=5.0l/pow(10.0l, static_cast<long double>(digits));
if(w>10)
{
// Rounding bumped us to the next exponent, deal with it