summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-05-02 12:37:06 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-05-02 13:08:51 -0700
commit34f9618d31532c7872bef4529eaa138527a320c9 (patch)
tree252e1423262638175727e5fe49e5c2312fea116e /include
parentfd0f9d1319408c2d33ba8571bcf66dc62f876159 (diff)
downloadqtlocation-mapboxgl-34f9618d31532c7872bef4529eaa138527a320c9.tar.gz
[core] Replace boost::lexical_cast with std::to_string
This removes the only boost dependency from public headers.
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/util/string.hpp32
1 files changed, 7 insertions, 25 deletions
diff --git a/include/mbgl/util/string.hpp b/include/mbgl/util/string.hpp
index 51ee848f22..d422a9d8f7 100644
--- a/include/mbgl/util/string.hpp
+++ b/include/mbgl/util/string.hpp
@@ -2,29 +2,23 @@
#define MBGL_UTIL_STRING
#include <string>
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunknown-pragmas"
-#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
-#include <boost/lexical_cast.hpp>
-#pragma GCC diagnostic pop
+#include <cassert>
+#include <exception>
namespace mbgl {
namespace util {
-template <typename... Args>
-inline std::string toString(Args&&... args) {
- return boost::lexical_cast<std::string>(::std::forward<Args>(args)...);
+template <class T>
+inline std::string toString(T t) {
+ return std::to_string(t);
}
-// boost::lexical_cast() treats this as a character, but we are using it as number types.
inline std::string toString(int8_t num) {
- return boost::lexical_cast<std::string>(int(num));
+ return std::to_string(int(num));
}
-// boost::lexical_cast() treats this as a character, but we are using it as number types.
inline std::string toString(uint8_t num) {
- return boost::lexical_cast<std::string>(unsigned(num));
+ return std::to_string(unsigned(num));
}
inline std::string toString(std::exception_ptr error) {
@@ -43,18 +37,6 @@ inline std::string toString(std::exception_ptr error) {
}
}
-template<size_t max, typename... Args>
-inline std::string sprintf(const char *msg, Args... args) {
- char res[max];
- int len = snprintf(res, sizeof(res), msg, args...);
- return std::string(res, len);
-}
-
-template<size_t max, typename... Args>
-inline std::string sprintf(const std::string &msg, Args... args) {
- return sprintf<max>(msg.c_str(), args...);
-}
-
} // namespace util
} // namespace mbgl