utils: Update error exception, utils.

This commit is contained in:
Dirk-Jan C. Binnema
2020-01-18 13:38:41 +02:00
parent 419871862c
commit a3d71dab91
3 changed files with 80 additions and 12 deletions

View File

@ -21,6 +21,7 @@
#define __MU_UTILS_HH__
#include <string>
#include <sstream>
#include <vector>
#include <cstdarg>
#include <glib.h>
@ -136,6 +137,24 @@ std::string size_to_string (const std::string& sizestr, bool first);
std::string size_to_string (int64_t size);
/**
* Convert any ostreamable<< value to a string
*
* @param t the value
*
* @return a std::string
*/
template <typename T>
static inline std::string to_string (const T& val)
{
std::stringstream sstr;
sstr << val;
return sstr.str();
}
/**
*
* don't repeat these catch blocks everywhere...