diff --git a/base/string_utils.hpp b/base/string_utils.hpp index 8fc2228b40..1ebec6dc13 100644 --- a/base/string_utils.hpp +++ b/base/string_utils.hpp @@ -1,6 +1,7 @@ #pragma once #include "base/buffer_vector.hpp" +#include "base/macros.hpp" #include "base/stl_add.hpp" #include @@ -337,28 +338,29 @@ bool IsInArray(T(&arr)[N], TT const & t) /// @name From string to numeric. //@{ -bool to_int(char const * s, int & i, int base = 10); -bool to_uint(char const * s, unsigned int & i, int base = 10); -bool to_uint64(char const * s, uint64_t & i); -bool to_int64(char const * s, int64_t & i); -bool to_float(char const * s, float & f); -bool to_double(char const * s, double & d); +WARN_UNUSED_RESULT bool to_int(char const * s, int & i, int base = 10); +WARN_UNUSED_RESULT bool to_uint(char const * s, unsigned int & i, int base = 10); +WARN_UNUSED_RESULT bool to_uint64(char const * s, uint64_t & i); +WARN_UNUSED_RESULT bool to_int64(char const * s, int64_t & i); +WARN_UNUSED_RESULT bool to_float(char const * s, float & f); +WARN_UNUSED_RESULT bool to_double(char const * s, double & d); -inline bool is_number(std::string const & s) +WARN_UNUSED_RESULT inline bool is_number(std::string const & s) { int64_t dummy; return to_int64(s.c_str(), dummy); } -inline bool to_int(std::string const & s, int & i, int base = 10) { return to_int(s.c_str(), i, base); } -inline bool to_uint(std::string const & s, unsigned int & i, int base = 10) +WARN_UNUSED_RESULT inline bool to_int(std::string const & s, int & i, int base = 10) { return to_int(s.c_str(), i, base); } +WARN_UNUSED_RESULT inline bool to_uint(std::string const & s, unsigned int & i, int base = 10) { return to_uint(s.c_str(), i, base); } -inline bool to_uint64(std::string const & s, uint64_t & i) { return to_uint64(s.c_str(), i); } -inline bool to_int64(std::string const & s, int64_t & i) { return to_int64(s.c_str(), i); } -inline bool to_float(std::string const & s, float & f) { return to_float(s.c_str(), f); } -inline bool to_double(std::string const & s, double & d) { return to_double(s.c_str(), d); } + +WARN_UNUSED_RESULT inline bool to_uint64(std::string const & s, uint64_t & i) { return to_uint64(s.c_str(), i); } +WARN_UNUSED_RESULT inline bool to_int64(std::string const & s, int64_t & i) { return to_int64(s.c_str(), i); } +WARN_UNUSED_RESULT inline bool to_float(std::string const & s, float & f) { return to_float(s.c_str(), f); } +WARN_UNUSED_RESULT inline bool to_double(std::string const & s, double & d) { return to_double(s.c_str(), d); } //@} /// @name From numeric to string.