try_dec_convert.hpp 825 B

1234567891011121314151617181920212223242526272829
  1. // Copyright Antony Polukhin, 2016-2019.
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See
  4. // accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_STACKTRACE_DETAIL_TRY_DEC_CONVERT_HPP
  7. #define BOOST_STACKTRACE_DETAIL_TRY_DEC_CONVERT_HPP
  8. #include <boost/config.hpp>
  9. #ifdef BOOST_HAS_PRAGMA_ONCE
  10. # pragma once
  11. #endif
  12. #include <cstdlib>
  13. namespace boost { namespace stacktrace { namespace detail {
  14. // We do not use boost::lexical_cast in this function to reduce module dependencies
  15. inline bool try_dec_convert(const char* s, std::size_t& res) BOOST_NOEXCEPT {
  16. char* end_ptr = 0;
  17. res = std::strtoul(s, &end_ptr, 10);
  18. return *end_ptr == '\0';
  19. }
  20. }}} // namespace boost::stacktrace::detail
  21. #endif // BOOST_STACKTRACE_DETAIL_TRY_DEC_CONVERT_HPP