diff options
Diffstat (limited to 'src/base/str.hh')
-rw-r--r-- | src/base/str.hh | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/base/str.hh b/src/base/str.hh index 1ea18b70d..48fccc8eb 100644 --- a/src/base/str.hh +++ b/src/base/str.hh @@ -85,12 +85,14 @@ to_lower(const std::string &s) } // Split the string s into lhs and rhs on the first occurence of the -// character c. +// character c. Character c is not included in either lhs or rhs. If +// character c is not contained within string s, lsh equals s. bool split_first(const std::string &s, std::string &lhs, std::string &rhs, char c); // Split the string s into lhs and rhs on the last occurence of the -// character c. +// character c. Character c is not included in either lhs or rhs. If +// character c is not contained within string s, lhs equals s. bool split_last(const std::string &s, std::string &lhs, std::string &rhs, char c); @@ -115,8 +117,10 @@ __to_number(const std::string &value) { // start big and narrow it down if needed, determine the base dynamically long long r = std::stoll(value, nullptr, 0); - if (r < std::numeric_limits<T>::min() || r > std::numeric_limits<T>::max()) + if (r < std::numeric_limits<T>::lowest() + || r > std::numeric_limits<T>::max()) { throw std::out_of_range("Out of range"); + } return static_cast<T>(r); } @@ -146,8 +150,10 @@ __to_number(const std::string &value) { // start big and narrow it down if needed long double r = std::stold(value); - if (r < std::numeric_limits<T>::min() || r > std::numeric_limits<T>::max()) + if (r < std::numeric_limits<T>::lowest() + || r > std::numeric_limits<T>::max()) { throw std::out_of_range("Out of range"); + } return static_cast<T>(r); } /** @} */ |