From 9585ecaed31238354c2a9bb2f52c14d17439a4d9 Mon Sep 17 00:00:00 2001 From: Walter Gray Date: Fri, 19 Aug 2016 16:15:09 -0700 Subject: [PATCH] Avoid use of to_string while we sort out WTF is going on with GCC 4.9 on android --- src/autowiring/marshaller.h | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/autowiring/marshaller.h b/src/autowiring/marshaller.h index bcb11d2b7..61943c727 100644 --- a/src/autowiring/marshaller.h +++ b/src/autowiring/marshaller.h @@ -6,7 +6,6 @@ #include #include -#undef _GLIBCXX_HAVE_BROKEN_VSWPRINTF //Enable to_string in GCC 4.8. #include #include #include @@ -108,8 +107,27 @@ namespace autowiring { typedef typename std::remove_volatile::type type; std::string marshal(const void* ptr) const override { - const type val = *static_cast(ptr); - return std::to_string(val); + std::string retVal; + type val = *static_cast(ptr); + if (val == 0) + return "0"; + + bool pos = 0 < val; + if (!pos) + val *= ~0; + for (; val; val /= 10) { + retVal.push_back(static_cast(val % 10 + '0')); + } + if (!pos) + retVal.push_back('-'); + + for ( + auto first = retVal.begin(), last = retVal.end(); + (first != last) && (first != --last); + ++first + ) + std::swap(*first, *last); + return retVal; } void unmarshal(void* ptr, const char* szValue) const override {