diff options
Diffstat (limited to 'absl/strings/numbers.h')
-rw-r--r-- | absl/strings/numbers.h | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/absl/strings/numbers.h b/absl/strings/numbers.h index 250d2603..e9878016 100644 --- a/absl/strings/numbers.h +++ b/absl/strings/numbers.h @@ -5,7 +5,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -38,48 +38,53 @@ #include "absl/strings/string_view.h" namespace absl { -inline namespace lts_2018_12_18 { +inline namespace lts_2019_08_08 { // SimpleAtoi() // // Converts the given string into an integer value, returning `true` if // successful. The string must reflect a base-10 integer (optionally followed or // preceded by ASCII whitespace) whose value falls within the range of the -// integer type. +// integer type. If any errors are encountered, this function returns `false`, +// leaving `out` in an unspecified state. template <typename int_type> -ABSL_MUST_USE_RESULT bool SimpleAtoi(absl::string_view s, int_type* out); +ABSL_MUST_USE_RESULT bool SimpleAtoi(absl::string_view str, int_type* out); // SimpleAtof() // // Converts the given string (optionally followed or preceded by ASCII // whitespace) into a float, which may be rounded on overflow or underflow. -// See http://en.cppreference.com/w/c/string/byte/strtof for details about the -// allowed formats for `str`. -ABSL_MUST_USE_RESULT bool SimpleAtof(absl::string_view str, float* value); +// See https://en.cppreference.com/w/c/string/byte/strtof for details about the +// allowed formats for `str`. If any errors are encountered, this function +// returns `false`, leaving `out` in an unspecified state. +ABSL_MUST_USE_RESULT bool SimpleAtof(absl::string_view str, float* out); // SimpleAtod() // // Converts the given string (optionally followed or preceded by ASCII // whitespace) into a double, which may be rounded on overflow or underflow. -// See http://en.cppreference.com/w/c/string/byte/strtof for details about the -// allowed formats for `str`. -ABSL_MUST_USE_RESULT bool SimpleAtod(absl::string_view str, double* value); +// See https://en.cppreference.com/w/c/string/byte/strtof for details about the +// allowed formats for `str`. If any errors are encountered, this function +// returns `false`, leaving `out` in an unspecified state. +ABSL_MUST_USE_RESULT bool SimpleAtod(absl::string_view str, double* out); // SimpleAtob() // // Converts the given string into a boolean, returning `true` if successful. // The following case-insensitive strings are interpreted as boolean `true`: // "true", "t", "yes", "y", "1". The following case-insensitive strings -// are interpreted as boolean `false`: "false", "f", "no", "n", "0". -ABSL_MUST_USE_RESULT bool SimpleAtob(absl::string_view str, bool* value); +// are interpreted as boolean `false`: "false", "f", "no", "n", "0". If any +// errors are encountered, this function returns `false`, leaving `out` in an +// unspecified state. +ABSL_MUST_USE_RESULT bool SimpleAtob(absl::string_view str, bool* out); -} // inline namespace lts_2018_12_18 +} // inline namespace lts_2019_08_08 } // namespace absl // End of public API. Implementation details follow. namespace absl { -inline namespace lts_2018_12_18 { +inline namespace lts_2019_08_08 { namespace numbers_internal { // safe_strto?() functions for implementing SimpleAtoi() @@ -178,11 +183,11 @@ ABSL_MUST_USE_RESULT bool safe_strtoi_base(absl::string_view s, int_type* out, // preceded by ASCII whitespace, with a value in the range of the corresponding // integer type. template <typename int_type> -ABSL_MUST_USE_RESULT bool SimpleAtoi(absl::string_view s, int_type* out) { - return numbers_internal::safe_strtoi_base(s, out, 10); +ABSL_MUST_USE_RESULT bool SimpleAtoi(absl::string_view str, int_type* out) { + return numbers_internal::safe_strtoi_base(str, out, 10); } -} // inline namespace lts_2018_12_18 +} // inline namespace lts_2019_08_08 } // namespace absl #endif // ABSL_STRINGS_NUMBERS_H_ |