Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:52:31

0001 // Copyright Antony Polukhin, 2016-2023.
0002 //
0003 // Distributed under the Boost Software License, Version 1.0. (See
0004 // accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef BOOST_STACKTRACE_DETAIL_TO_DEC_ARRAY_HPP
0008 #define BOOST_STACKTRACE_DETAIL_TO_DEC_ARRAY_HPP
0009 
0010 #include <boost/config.hpp>
0011 #ifdef BOOST_HAS_PRAGMA_ONCE
0012 #   pragma once
0013 #endif
0014 
0015 #include <array>
0016 #include <cstddef>  // std::size_t
0017 
0018 namespace boost { namespace stacktrace { namespace detail {
0019 
0020 // We do not use boost::lexical_cast in this function to reduce module dependencies
0021 inline std::array<char, 40> to_dec_array(std::size_t value) noexcept {
0022     std::array<char, 40> ret;
0023     if (!value) {
0024         ret[0] = '0';
0025         ret[1] = '\0';
0026         return ret;
0027     }
0028 
0029     std::size_t digits = 0;
0030     for (std::size_t value_copy = value; value_copy; value_copy /= 10) {
0031         ++ digits;
0032     }
0033 
0034     for (std::size_t i = 1; i <= digits; ++i) {
0035         ret[digits - i] = static_cast<char>('0' + (value % 10));
0036         value /= 10;
0037     }
0038 
0039     ret[digits] = '\0';
0040 
0041     return ret;
0042 }
0043 
0044 
0045 }}} // namespace boost::stacktrace::detail
0046 
0047 #endif // BOOST_STACKTRACE_DETAIL_TO_DEC_ARRAY_HPP