Skip to content

Commit

Permalink
Remove dependency on std::to_string
Browse files Browse the repository at this point in the history
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
  • Loading branch information
scannell authored and Dave Watson committed Sep 18, 2014
1 parent 079e4ff commit 1e06d08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions folly/Conv.h
Expand Up @@ -42,9 +42,12 @@
// V8 JavaScript implementation
#include <double-conversion/double-conversion.h>

#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 {
Expand Down Expand Up @@ -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_ */
3 changes: 2 additions & 1 deletion folly/IPAddress.h
Expand Up @@ -24,6 +24,7 @@

#include <boost/operators.hpp>

#include <folly/Conv.h>
#include <folly/Format.h>
#include <folly/Range.h>
#include <folly/IPAddressException.h>
Expand Down Expand Up @@ -98,7 +99,7 @@ class IPAddress : boost::totally_ordered<IPAddress> {
* @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<std::string>(network.second);
}

/**
Expand Down

0 comments on commit 1e06d08

Please sign in to comment.