Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93e02985 authored by Tom Cherry's avatar Tom Cherry Committed by Gerrit Code Review
Browse files

Merge "Assert that ParseInt/ParseUint are only used with signed/unsigned numbers respectively"

parents c35c6099 bc64e50b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@

#include <limits>
#include <string>
#include <type_traits>

namespace android {
namespace base {
@@ -33,6 +34,7 @@ namespace base {
template <typename T>
bool ParseUint(const char* s, T* out, T max = std::numeric_limits<T>::max(),
               bool allow_suffixes = false) {
  static_assert(std::is_unsigned<T>::value, "ParseUint can only be used with unsigned types");
  while (isspace(*s)) {
    s++;
  }
@@ -96,6 +98,7 @@ template <typename T>
bool ParseInt(const char* s, T* out,
              T min = std::numeric_limits<T>::min(),
              T max = std::numeric_limits<T>::max()) {
  static_assert(std::is_signed<T>::value, "ParseInt can only be used with signed types");
  while (isspace(*s)) {
    s++;
  }