24 #ifndef ABSL_STRINGS_NUMBERS_H_ 25 #define ABSL_STRINGS_NUMBERS_H_ 33 #include <type_traits> 49 template <
typename int_type>
85 namespace numbers_internal {
114 template <
typename int_type>
116 static_assert(
sizeof(i) <= 64 / 8,
117 "FastIntToBuffer works only with 64-bit-or-less integers.");
121 if (static_cast<int_type>(1) - 2 < 0) {
122 if (
sizeof(i) > 32 / 8) {
128 if (
sizeof(i) > 32 / 8) {
138 template <
typename int_type>
141 static_assert(
sizeof(*out) == 4 ||
sizeof(*out) == 8,
142 "SimpleAtoi works only with 32-bit or 64-bit integers.");
144 "Use SimpleAtof or SimpleAtod instead.");
149 if (static_cast<int_type>(1) - 2 < 0) {
150 if (
sizeof(*out) == 64 / 8) {
153 *out =
static_cast<int_type
>(val);
157 *out =
static_cast<int_type
>(val);
160 if (
sizeof(*out) == 64 / 8) {
163 *out =
static_cast<int_type
>(val);
167 *out =
static_cast<int_type
>(val);
182 template <
typename int_type>
189 #endif // ABSL_STRINGS_NUMBERS_H_ bool safe_strtou64_base(absl::string_view text, uint64_t *value, int base)
char * FastIntToBuffer(int32_t, char *)
size_t SixDigitsToBuffer(double d, char *buffer)
bool safe_strtou32_base(absl::string_view text, uint32_t *value, int base)
bool SimpleAtod(absl::string_view str, double *out)
bool SimpleAtof(absl::string_view str, float *out)
bool safe_strto32_base(absl::string_view text, int32_t *value, int base)
ABSL_MUST_USE_RESULT bool SimpleAtoi(absl::string_view s, int_type *out)
#define ABSL_MUST_USE_RESULT
static const int kSixDigitsToBufferSize
ABSL_MUST_USE_RESULT bool safe_strtoi_base(absl::string_view s, int_type *out, int base)
bool safe_strto64_base(absl::string_view text, int64_t *value, int base)
static const int kFastToBufferSize
bool SimpleAtob(absl::string_view str, bool *out)