Files
MapLibreParticleLab/include/mbgl/util/string.hpp
John Firebaugh 34f9618d31 [core] Replace boost::lexical_cast with std::to_string
This removes the only boost dependency from public headers.
2016-05-02 13:08:51 -07:00

44 lines
762 B
C++

#ifndef MBGL_UTIL_STRING
#define MBGL_UTIL_STRING
#include <string>
#include <cassert>
#include <exception>
namespace mbgl {
namespace util {
template <class T>
inline std::string toString(T t) {
return std::to_string(t);
}
inline std::string toString(int8_t num) {
return std::to_string(int(num));
}
inline std::string toString(uint8_t num) {
return std::to_string(unsigned(num));
}
inline std::string toString(std::exception_ptr error) {
assert(error);
if (!error) {
return "(null)";
}
try {
std::rethrow_exception(error);
} catch (const std::exception& ex) {
return ex.what();
} catch (...) {
return "Unknown exception type";
}
}
} // namespace util
} // namespace mbgl
#endif