From 1e06d0814a84dc064f09b8b6aed4bb0a63798619 Mon Sep 17 00:00:00 2001 From: Sean Cannella Date: Thu, 18 Sep 2014 07:20:04 -0700 Subject: [PATCH] Remove dependency on std::to_string Summary: Mobile platform clang doesn't currently support std::to_string so remove folly's dependency on it. Test Plan: existing tests Reviewed By: mpawlowski@fb.com Subscribers: kmdent, fma, benyluo, shikong, ranjeeth, subodh, pgriess, njormrod FB internal diff: D1562179 Tasks: 5183325 --- folly/Conv.h | 11 ++++++++--- folly/IPAddress.h | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/folly/Conv.h b/folly/Conv.h index 76b9385c..798c2732 100644 --- a/folly/Conv.h +++ b/folly/Conv.h @@ -42,9 +42,12 @@ // V8 JavaScript implementation #include -#define FOLLY_RANGE_CHECK(condition, message) \ - ((condition) ? (void)0 : throw std::range_error( \ - (__FILE__ "(" + std::to_string((long long int) __LINE__) + "): " \ +#define FOLLY_RANGE_CHECK_STRINGIZE(x) #x +#define FOLLY_RANGE_CHECK_STRINGIZE2(x) FOLLY_RANGE_CHECK_STRINGIZE(x) + +#define FOLLY_RANGE_CHECK(condition, message) \ + ((condition) ? (void)0 : throw std::range_error( \ + (std::string(__FILE__ "(" FOLLY_RANGE_CHECK_STRINGIZE2(__LINE__) "): ") \ + (message)).c_str())) namespace folly { @@ -1407,6 +1410,8 @@ to(const Src & value) { // to avoid defining this global macro name in other files that include Conv.h. #ifndef FOLLY_CONV_INTERNAL #undef FOLLY_RANGE_CHECK +#undef FOLLY_RANGE_CHECK_STRINGIZE2 +#undef FOLLY_RANGE_CHECK_STRINGIZE #endif #endif /* FOLLY_BASE_CONV_H_ */ diff --git a/folly/IPAddress.h b/folly/IPAddress.h index 7820fa47..b1c474a6 100644 --- a/folly/IPAddress.h +++ b/folly/IPAddress.h @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -98,7 +99,7 @@ class IPAddress : boost::totally_ordered { * @return string representing the netblock */ static std::string networkToString(const CIDRNetwork& network) { - return network.first.str() + "/" + std::to_string(network.second); + return network.first.str() + "/" + folly::to(network.second); } /** -- 2.34.1