summaryrefslogtreecommitdiff
path: root/include/mbgl/util/string.hpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-12-04 12:59:09 +0100
committerKonstantin Käfer <mail@kkaefer.com>2014-12-04 12:59:09 +0100
commitb449b22abcceddab154e1694eb4f8ca8e392e35f (patch)
treea4dfeb8d2c52fe2877863625465dca385952dad1 /include/mbgl/util/string.hpp
parent65451187f50de0ca5e76f0f10d7cfa51dac867c2 (diff)
downloadqtlocation-mapboxgl-b449b22abcceddab154e1694eb4f8ca8e392e35f.tar.gz
remove use of std::to_string in favor of boost::lexical_cast
std::to_string calls sprintf() internally, which is really slow
Diffstat (limited to 'include/mbgl/util/string.hpp')
-rw-r--r--include/mbgl/util/string.hpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/mbgl/util/string.hpp b/include/mbgl/util/string.hpp
index f17d55cec3..690a67d471 100644
--- a/include/mbgl/util/string.hpp
+++ b/include/mbgl/util/string.hpp
@@ -3,9 +3,27 @@
#include <string>
+#pragma GCC diagnostic push
+#ifndef __clang__
+#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
+#endif
+#include <boost/lexical_cast.hpp>
+#pragma GCC diagnostic pop
+
namespace mbgl {
namespace util {
+template <typename... Args>
+inline std::string toString(Args&&... args) {
+ return boost::lexical_cast<std::string>(::std::forward<Args>(args)...);
+}
+
+// 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));
+}
+
+
template<size_t max, typename... Args>
inline std::string sprintf(const char *msg, Args... args) {
char res[max];