]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/stacktrace/detail/to_dec_array.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / stacktrace / detail / to_dec_array.hpp
CommitLineData
1e59de90 1// Copyright Antony Polukhin, 2016-2022.
92f5a8d4
TL
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
7#ifndef BOOST_STACKTRACE_DETAIL_TO_DEC_ARRAY_HPP
8#define BOOST_STACKTRACE_DETAIL_TO_DEC_ARRAY_HPP
9
10#include <boost/config.hpp>
11#ifdef BOOST_HAS_PRAGMA_ONCE
12# pragma once
13#endif
14
15#include <boost/array.hpp>
16
17namespace boost { namespace stacktrace { namespace detail {
18
19// We do not use boost::lexical_cast in this function to reduce module dependencies
20inline boost::array<char, 40> to_dec_array(std::size_t value) BOOST_NOEXCEPT {
21 boost::array<char, 40> ret;
22 if (!value) {
23 ret[0] = '0';
24 ret[1] = '\0';
25 return ret;
26 }
27
28 std::size_t digits = 0;
29 for (std::size_t value_copy = value; value_copy; value_copy /= 10) {
30 ++ digits;
31 }
32
33 for (std::size_t i = 1; i <= digits; ++i) {
34 ret[digits - i] = static_cast<char>('0' + (value % 10));
35 value /= 10;
36 }
37
38 ret[digits] = '\0';
39
40 return ret;
41}
42
43
44}}} // namespace boost::stacktrace::detail
45
46#endif // BOOST_STACKTRACE_DETAIL_TO_DEC_ARRAY_HPP