diff --git a/base/include/android-base/parseint.h b/base/include/android-base/parseint.h index 9444fddf0ae66f8242f192eff0aebe3076336053..be8b97b788eed9f93e2be4346278f3cafcac3711 100644 --- a/base/include/android-base/parseint.h +++ b/base/include/android-base/parseint.h @@ -22,6 +22,7 @@ #include #include +#include namespace android { namespace base { @@ -33,6 +34,7 @@ namespace base { template bool ParseUint(const char* s, T* out, T max = std::numeric_limits::max(), bool allow_suffixes = false) { + static_assert(std::is_unsigned::value, "ParseUint can only be used with unsigned types"); while (isspace(*s)) { s++; } @@ -96,6 +98,7 @@ template bool ParseInt(const char* s, T* out, T min = std::numeric_limits::min(), T max = std::numeric_limits::max()) { + static_assert(std::is_signed::value, "ParseInt can only be used with signed types"); while (isspace(*s)) { s++; }