P2587R2
to_string or not to_string

Published Proposal,

Author:
Audience:
LEWG
Project:
ISO/IEC JTC1/SC22/WG21 14882: Programming Language — C++

"Though this be madness, yet there is method in ’t." ― Polonius

1. Introduction

C++11 introduced a set of std::to_string overloads for integral and floating-point types. Fortunately for integral and unfortunately for floating-point overloads they are all defined in terms of sprintf inconsistently with C++ formatted output functions ([N4910]). Additionally, the choice of the floating-point format makes std::to_string of very limited use in practice. This paper proposes fixing these issues while retaining existing semantics of integral overloads.

2. Revision history

Changes since R1:

Changes since R0:

3. LEWG Polls

Poll: Fix to_string as proposed by P2587R1 (to-string or not to_string).

SF F N A SA
4 9 3 2 1

Outcome: Weak consensus

4. Examples

Consider the following example:

auto loc = std::locale("uk_UA.UTF-8");
std::locale::global(loc);
std::cout.imbue(loc);
setlocale(LC_ALL, "C");

std::cout << "iostreams:\n";
std::cout << 1234 << "\n";
std::cout << 1234.5 << "\n";

std::cout << "\nto_string:\n";
std::cout << std::to_string(1234) << "\n";
std::cout << std::to_string(1234.5) << "\n";

setlocale(LC_ALL, "uk_UA.UTF-8");

std::cout << "\nto_string (uk_UA.UTF-8 C locale):\n";
std::cout << std::to_string(1234) << "\n";
std::cout << std::to_string(1234.5) << "\n";

It prints:

iostreams:
1 234
1 234,5

to_string:
1234
1234.500000

to_string (uk_UA.UTF-8 C locale):
1234
1234,500000

Since std::to_string uses the global C locale and no grouping the integral overloads are effectively unlocalized. The output of floating-point overloads is inconsistent with that of iostreams because the former takes the decimal point from the global C locale and doesn’t do grouping.

Additionally, due to an unfortunate choice of the fixed format in the floating-point overloads they are only useful for numbers in a limited exponent range. For example:

std::cout << std::to_string(std::numeric_limits<double>::max());

prints

1797693134862315708145274237317043567980705675258449965989174768031572607800285
3876058955863276687817154045895351438246423432132688946418276846754670353751698
6049910576551282076245490090389328944075868508455133942304583236903222948165808
559332123348274797826204144723168738177180919299881250404026184124858368.000000
(line breaks inserted for readability)

Here only the first 17 digits are meaningful, the next 292 are so-called "garbage" digits ([DRAGON]). And finally we have 6 meaningless zeros after a possibly localized decimal point.

Formatting of small floating-point numbers is even less useful. For example:

std::cout << std::to_string(-1e-7);

prints

-0.000000

In fact almost half of floating-point numbers are formatted as zero and there is a precision loss or garbage digit output in many other cases.

Unfortunately issues with floating-point overloads of std::to_string have not been discussed in the paper that proposed this facility ([N1803], [N2408]). However, they were brought up as early as 2015 in a mailing list discussion ([STD_DISCUSSION]) which proposed deprecating floating-point overloads of std::to_string but no paper came out of that.

5. Proposal

Redefine std::to_string in terms of std::format which in turn uses std::to_chars making more explicit the fact that integral overloads are unlocalized and changing the format of floating-point overloads to also be unlocalized and use the shortest decimal representation.

The following table shows the changes in output for the following code:

setlocale(LC_ALL, "C");
auto output = std::to_string(input);
input output
before after
42 42 42
0.42 0.420000 0.42
-1e-7 -0.000000 -1e-7
1.7976931348623157e+308 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 1.7976931348623157e+308

and similarly with the global C locale set:

setlocale(LC_ALL, "uk_UA.UTF-8");
auto output = std::to_string(input);
input output
before after
12345 12345 12345
1234.5 1234,500000 1234.5

In addition to fixing the broken behavior for floating point, this proposal enables an easy and natural extension of std::to_string to other types via std::format (not proposed in this paper).

6. Impact on existing code

This change will affect the output of std::to_string with floating-point arguments. In most cases it will result in a more precise and/or shorter output. In cases where the C locale is explicitly set the decimal point will no longer be localized.

In order to estimate the practical impact on existing code we looked at [CODESEARCH] results for std::to_string. 876 million lines of code contained only ~11 thousand calls to this function. For comparison, there are ~20 thousand uses of std::stringstream and ~390 thousand calls to sprintf. We further analyzed a random sample of 100 std::to_string invocations listed in Appendix A. 91 of them are called with integral arguments and only 7 contain calls with floating-point arguments. Note that some of these 7 results contain calls with integral and FP arguments on the same line. The two remaining cases are a generic wrapper around std::to_string and an overload for a user-defined type.

Three of the seven FP calls are in test code with one of them used to format zero:

actcd19/main/g/gnss-sdr/gnss-sdr_0.0.10-4/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc:916

                                                                g5.disablescreen();    
}
g5.set_title("Code delay error, PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_idx)) + "," + std::to_string(DLL_wide_bw_values.at(config_idx)) + " Hz (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
g5.set_grid();
g5.set_xlabel("Time [s]");


actcd19/main/g/gnss-sdr/gnss-sdr_0.0.9-5/src/tests/system-tests/obs_gps_l1_system_test.cc:229

        config->set_property("SignalSource.sampling_frequency", std::to_string(sampling_rate_internal));    
config->set_property("SignalSource.item_type", "ibyte");
config->set_property("SignalSource.samples", std::to_string(zero));

// Set the Signal Conditioner


actcd19/main/t/trilinos/trilinos_12.12.1-7/packages/stk/stk_simd/unit_tests/SimdFixture.hpp:268

        
virtual std::string get_input_vals(int i) const override {
return std::to_string(x.scalar(i))+" "+std::to_string(y.scalar(i));
}
};

Two of the calls are used for informational messages (writing a comment to a file and printing status):

actcd19/main/p/pdal/pdal_1.7.2-2/vendor/kazhdan/SurfaceTrimmerMain.cpp:127

        if (Trim.set)    
comments.push_back(leader + Trim.name + " " +
std::to_string(Trim.value));
if (Smooth.set)
comments.push_back(leader + IslandAreaRatio.name + " " +


actcd19/main/m/madness/madness_0.10.1~gite4aa500e-3/src/apps/chem/CC2.cc:131

        bool doubles_converged = true;    
for(size_t iter=0; iter < parameters.iter_max_6D; iter++){
output_subsection("Mactoiteration " + std::to_string(iter) + " with excitation energy " + std::to_string(omega));
CC_Timer timer_iter_all(world,"Macroiteration " + stringify(iter));


In one case std::to_string is used to write an FP value to a config file. It is likely a latent bug because writing a config in one locale may render it unreadable in a different one unless special measures are taken to fix the locale.

actcd19/main/p/performous/performous_1.1+git20181118-2/game/configuration.cc:310

    		else if (type == "int") entryNode->set_attribute("value",std::to_string(item.i()));    
else if (type == "bool") entryNode->set_attribute("value", item.b() ? "true" : "false");
else if (type == "float") entryNode->set_attribute("value",std::to_string(item.f()));
else if (item.get_type() == "string") xmlpp::add_child_element(entryNode, "stringvalue")->add_child_text(item.s());
else if (item.get_type() == "string_list") {


The last call is used to generate a human-readable name for some object, possibly for debug purposes. We haven’t found any uses of the enclosing function though.

actcd19/main/p/psi4/psi4_1.2.1-2/psi4/src/psi4/libmints/cdsalclist.cc:312

        
name += com.coef > 0.0 ? "+" : "-";
name += std::to_string(std::fabs(com.coef)) + " ";
name += molecule_->label(com.atom);
if (com.xyz == 0)


In summary, the number of uses of to_string with floating point arguments turned out to be very low and the cases that we analyzed are mostly non-critical such as tests and debugging/logging use cases. Some of them may even contain latent bugs because the use of the locale is unintentional.

As a mitigation mechanism we could provide to_string_localized (not currently proposed) with the old behavior which would provide a simple migration path.

7. Implementation

{fmt} implements proposed changes in fmt::to_string.

8. Wording

Add an entry for __cpp_lib_to_string to section "Header <version> synopsis [version.syn]", in a place that respects the table’s current alphabetic order:

#define __cpp_lib_to_string **placeholder**  // also in <string>

Modify subsection "Numeric conversions [string.conversions]":

string to_string(int val);
string to_string(unsigned val);
string to_string(long val);
string to_string(unsigned long val);
string to_string(long long val);
string to_string(unsigned long long val);
string to_string(float val);
string to_string(double val);
string to_string(long double val);
7 Returns: Each function returns a string object holding the character representation of the value of its argument that would be generated by calling sprintf(buf, fmt, val) with a format specifier of "%d", "%u", "%ld", "%lu", "%lld", "%llu", "%f", "%f", or "%Lf", respectively, where buf designates an internal character buffer of sufficient size.

7 Returns: format("{}", val).

wstring to_wstring(int val);
wstring to_wstring(unsigned val);
wstring to_wstring(long val);
wstring to_wstring(unsigned long val);
wstring to_wstring(long long val);
wstring to_wstring(unsigned long long val);
wstring to_wstring(float val);
wstring to_wstring(double val);
wstring to_wstring(long double val);
14 Returns: Each function returns a wstring object holding the character representation of the value of its argument that would be generated by calling swprintf(buf, buffsz, fmt, val) with a format specifier of L"%d", L"%u", L"%ld", L"%lu", L"%lld", L"%llu", L"%f", L"%f", or L"%Lf", respectively, where buf designates an internal character buffer of sufficient size buffsz.

14 Returns: format(L"{}", val).

Add to Annex C (informative) Compatibility [diff] the following new subclause:

C.? C++ and ISO C++ 2026 [diff.cpp23]

This subclause lists the differences between C++ and ISO C++ 2023 (ISO/IEC 14882:2023, Programming Languages — C++), by the chapters of this document.

C.?.1 Clause 23: strings library [diff.cpp23.strings]

Affected subclauses: 23.4
Change: Output of floating-point overloads of to_string and to_wstring.
Rationale: Prevent loss of information and improve consistency with other formatting facilities.
Effect on original feature: to_string and to_wstring function calls that take floating-point arguments may produce a different output. For example:

auto s = std::to_string(1e-7); // "1e-7"
                               // previously "0.000000" with '.' possibly
                               // changed according to the global C locale

Appendix A: Sample of code search results for to_string

Searching for std::to_string...

2489599 source files searched.

11408 matches found.

Here is a random sample of matches...


actcd19/main/u/ultracopier/ultracopier_1.6.1.3-1/plugins/Themes/Oxygen/ThemesFactory.cpp:339

        if(!ui->checkBoxShowSpeed->isChecked())    
return;
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"value: "+std::to_string(value));
switch(value)
{


actcd19/main/r/re2/re2_20190101+dfsg-2/re2/testing/re2_test.cc:870

        ASSERT_TRUE(RE2::FullMatch("-100", "(-?\\d+)", &v2)); ASSERT_EQ(v2, -100);    

str = std::to_string(max);
ASSERT_TRUE(RE2::FullMatch(str, "(-?\\d+)", &v)); ASSERT_EQ(v, max);


actcd19/main/s/scilab/scilab_6.0.1-7/modules/hdf5/src/cpp/handle_properties.cpp:2683

                dims[0] = 1;    
dims[1] = static_cast<int>(path.size());
writeIntegerMatrix6(node, std::to_string(i).data(), H5T_NATIVE_INT32, "32", 2, dims, path.data());
}
}


actcd19/main/r/rosegarden/rosegarden_18.12-1/src/sound/MidiEvent.cpp:181

                    sharpflat = std::to_string(-tonality) + " flat";    
} else {
sharpflat = std::to_string(tonality);
sharpflat += " sharp";
}


actcd19/main/n/nheko/nheko_0.6.3-1/mtxclient/lib/http/client.cpp:137

    {    
std::map<std::string, std::string> params;
params.emplace("limit", std::to_string(limit));

get<mtx::responses::Notifications>(


actcd19/main/u/ultracopier/ultracopier_1.6.1.3-1/plugins/CopyEngine/Ultracopier/WriteThread.cpp:72

        if(stopIt)    
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"["+std::to_string(id)+"] close because stopIt is at true");
emit closed();
return false;


actcd19/main/p/pdns/pdns_4.1.6-1/pdns/dnsname.cc:125

          if(newpos < offset) {    
if(newpos < (int) minOffset)
throw std::range_error("Invalid label position during decompression ("+std::to_string(newpos)+ " < "+std::to_string(minOffset)+")");
if (++depth > 100)
throw std::range_error("Abort label decompression after 100 redirects");


actcd19/main/c/chromium/chromium_72.0.3626.121-1/chrome/browser/ui/search/local_ntp_browsertest.cc:637

      for (int i = kDefaultMostVisitedItemCount; i < kDefaultCustomLinkMaxCount;    
++i) {
std::string rid = std::to_string(i + 100);
std::string url = "https://" + rid + ".com";
std::string title = "url for " + rid;


actcd19/main/s/simgrid/simgrid_3.21+dfsg-4/docs/source/tuto_s4u/master-workers-lab4.cpp:62

        /* - Select a worker in a round-robin way */    
aid_t worker_pid = actors.at(task_id % actors.size())->get_pid();
std::string mailbox_name = std::string("worker-") + std::to_string(worker_pid);
simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);


actcd19/main/s/sysdig/sysdig_0.22.0-1/userspace/libsinsp/mesos.cpp:618

    								if(m_inactive_frameworks.size())    
{
g_logger.log("Collection detected " + std::to_string(m_inactive_frameworks.size()) + " inactive frameworks",
sinsp_logger::SEV_DEBUG);
}


actcd19/main/d/dnsdist/dnsdist_1.3.3-2/dns.cc:88

        if(offset < d_length)    
return d_ptr[offset];
throw runtime_error("out of bounds: "+std::to_string(offset)+" >= " + std::to_string(d_length));
}
private:


actcd19/main/c/chromium/chromium_72.0.3626.121-1/extensions/browser/api/display_source/display_source_apitestbase.cc:487

        net_result = socket_->Bind(local_point);    
if (net_result == net::OK) {
udp_port_ = std::to_string(port);
// When we got an udp socket established and udp port is known
// Change sink’s status to connected and proceed with the test.


actcd19/main/p/pdns/pdns_4.1.6-1/pdns/validate.cc:1054

        
if (!DNSCryptoKeyEngine::isDigestSupported(ds.d_digesttype)) {
LOG("Discarding DS "<<ds.d_tag<<" because we don’t support digest number "<<std::to_string(ds.d_digesttype)<<endl);
return false;
}


actcd19/main/d/dnsdist/dnsdist_1.3.3-2/fstrm_logger.cc:24

        res = fstrm_writer_options_add_content_type(d_fwopt, DNSTAP_CONTENT_TYPE, sizeof(DNSTAP_CONTENT_TYPE) - 1);    
if (res != fstrm_res_success) {
throw std::runtime_error("FrameStreamLogger: fstrm_writer_options_add_content_type failed: " + std::to_string(res));
}


actcd19/main/p/pdal/pdal_1.7.2-2/vendor/kazhdan/SurfaceTrimmerMain.cpp:127

        if (Trim.set)    
comments.push_back(leader + Trim.name + " " +
std::to_string(Trim.value));
if (Smooth.set)
comments.push_back(leader + IslandAreaRatio.name + " " +


actcd19/main/p/pybind11/pybind11_2.2.4-2/tests/test_kwargs_and_defaults.cpp:15

        
TEST_SUBMODULE(kwargs_and_defaults, m) {
auto kw_func = [](int x, int y) { return "x=" + std::to_string(x) + ", y=" + std::to_string(y); };

// test_named_arguments


actcd19/main/p/pdns-recursor/pdns-recursor_4.1.11-1/dnsparser.cc:652

        if(d_notyouroffset > d_length)    
throw std::out_of_range("dns packet out of range: "+std::to_string(d_notyouroffset) +" > "
+ std::to_string(d_length) );
}
void rewindOffset(uint16_t by)


actcd19/main/c/chromium/chromium_72.0.3626.121-1/third_party/webrtc/rtc_base/string_to_number_unittest.cc:47

      constexpr T zero_value = 0;    
const std::string min_string = std::to_string(min_value);
const std::string max_string = std::to_string(max_value);
EXPECT_EQ(min_value, StringToNumber<T>(min_string));
EXPECT_EQ(min_value, StringToNumber<T>(min_string.c_str()));


actcd19/main/c/chromium/chromium_72.0.3626.121-1/.pc/disable/tracing.patch/content/browser/browser_child_process_host_impl.cc:415

      std::string log_message = "Bad message received of type: ";    
if (message.IsValid()) {
log_message += std::to_string(message.type());
} else {
log_message += "unknown";


actcd19/main/q/qtwebengine-opensource-src/qtwebengine-opensource-src_5.11.3+dfsg-2/src/3rdparty/chromium/third_party/swiftshader/third_party/subzero/src/IceInst.cpp:603

            Ctx, ".L" + FuncName.toString() + "$jumptable$__" + std::to_string(Id));    
return GlobalString::createWithString(
Ctx, "$J" + std::to_string(FuncName.getID()) + "_" + std::to_string(Id));
}
} // end of anonymous namespace


actcd19/main/r/rocksdb/rocksdb_5.17.2-3/examples/compact_files_example.cc:155

      // because of options.level0_stop_writes_trigger    
for (int i = 1000; i < 99999; ++i) {
db->Put(WriteOptions(), std::to_string(i),
std::string(500, 'a' + (i % 26)));
}


actcd19/main/t/trilinos/trilinos_12.12.1-7/packages/seacas/libraries/ioss/src/xdmf/Ioxf_DatabaseIO.C:1054

        
std::string FinalName(hdfname.tailname().c_str());
FinalName += ":/" + block_name + "/Iteration " + std::to_string(step) + "/" + var_name;
XdmfArray *ScalarArray = new XdmfArray();
if (sizeof(double) == 8)


actcd19/main/q/qtwebengine-opensource-src/qtwebengine-opensource-src_5.11.3+dfsg-2/src/3rdparty/chromium/third_party/swiftshader/src/OpenGL/compiler/preprocessor/Macro.cpp:40

    	Token token;    
token.type = Token::CONST_INT;
token.text = std::to_string(value);

std::shared_ptr<Macro> macro = std::make_shared<Macro>();


actcd19/main/g/gnss-sdr/gnss-sdr_0.0.10-4/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc:916

                                                                g5.disablescreen();    
}
g5.set_title("Code delay error, PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_idx)) + "," + std::to_string(DLL_wide_bw_values.at(config_idx)) + " Hz (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
g5.set_grid();
g5.set_xlabel("Time [s]");


actcd19/main/a/antlr4-cpp-runtime/antlr4-cpp-runtime_4.7.2+dfsg-1/runtime/src/atn/ATNSerializer.cpp:475

        size_t s = data[p++];    
buf.append("mode ")
.append(std::to_string(i))
.append(":")
.append(std::to_string(s))


actcd19/main/q/qtwebengine-opensource-src/qtwebengine-opensource-src_5.11.3+dfsg-2/src/3rdparty/chromium/third_party/perfetto/src/protozero/protoc_plugin/protozero_generator.cc:322

          stub_h_->Print("$name$ = $number$,\n", "name",    
value_name_prefix + value->name(), "number",
std::to_string(value->number()));
}


actcd19/main/g/gnss-sdr/gnss-sdr_0.0.10-4/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc:559

                        try    
{
d_dump_filename.append(std::to_string(d_channel));
d_dump_filename.append(".dat");
d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);


actcd19/main/u/ultracopier/ultracopier_1.6.1.3-1/plugins/CopyEngine/Ultracopier/ReadThread.cpp:623

    bool ReadThread::internalReopen()    
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"["+std::to_string(id)+"] start");
stopIt=false;
if(file.isOpen())


actcd19/main/c/chromium/chromium_72.0.3626.121-1/third_party/webrtc/modules/video_coding/codecs/test/videocodec_test_mediacodec.cc:137

          const int width = std::get<0>(resolution);    
const int height = std::get<1>(resolution);
config.filename = std::string("foreman_") + std::to_string(width) + "x" +
std::to_string(height);
config.filepath = ResourcePath(config.filename, "yuv");


actcd19/main/b/bedops/bedops_2.4.35+dfsg-1/interfaces/general-headers/data/bed/Bed.hpp:389

        
static const std::string tab = "\t";
return std::string(chrom_) + tab + std::to_string(start_) + tab + std::to_string(end_) + tab
+ std::string(id_);
}


actcd19/main/g/gnss-sdr/gnss-sdr_0.0.10-4/src/core/receiver/gnss_block_factory.cc:189

                if (ID != -1)    
{
role = "SignalSource" + std::to_string(ID);
}
}


actcd19/main/m/mariadb-10.3/mariadb-10.3_10.3.13-1/storage/rocksdb/rdb_i_s.cc:498

            {"TARGET_FILE_SIZE_BASE", std::to_string(opts.target_file_size_base)},    
{"TARGET_FILE_SIZE_MULTIPLIER",
std::to_string(opts.target_file_size_multiplier)},
{"MAX_BYTES_FOR_LEVEL_BASE",
std::to_string(opts.max_bytes_for_level_base)},


actcd19/main/c/cmake/cmake_3.12.3-3/Source/cmStateSnapshot.cxx:338

                          std::to_string(cmVersion::GetMajorVersion()));    
this->SetDefinition("CMAKE_MINOR_VERSION",
std::to_string(cmVersion::GetMinorVersion()));
this->SetDefinition("CMAKE_PATCH_VERSION",
std::to_string(cmVersion::GetPatchVersion()));


actcd19/main/p/pdns/pdns_4.1.6-1/pdns/pkcs11signers.cc:234

          } else {    
logError("C_GetTokenInfo");
throw PDNSException("Cannot get token info for slot " + std::to_string(slot));
}
}


actcd19/main/g/gnss-sdr/gnss-sdr_0.0.10-4/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc:112

                            {    
d_dump_filename = "telemetry_L2CM_";
d_dump_filename.append(std::to_string(d_channel));
d_dump_filename.append(".dat");
d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);


actcd19/main/s/scilab/scilab_6.0.1-7/modules/hdf5/src/cpp/handle_properties.cpp:984

            int col = 0;    
int* path = nullptr;
getHandleIntVector(node, std::to_string(i).data(), &row, &col, &path);
std::vector<int> res(row * col);
for (int j = 0; j < row * col; ++j)


actcd19/main/p/pdal/pdal_1.7.2-2/vendor/arbiter/arbiter.cpp:1447

        if (!headers.count("Content-Length"))    
{
headers["Content-Length"] = std::to_string(data.size());
}
return m_pool.acquire().post(typedPath(path), data, headers, query);


actcd19/main/f/fw4spl/fw4spl_17.2.0-2/SrcLib/core/fwCommand/test/tu/src/UndoRedoManagerTest.cpp:229

        {    
BogusCommand::sptr testCmdI =
std::make_shared<BogusCommand>(BogusCommand("testCmd" + std::to_string(i), log, CMDSIZE));

undoRedoManager.enqueue(testCmdI);


actcd19/main/s/sysdig/sysdig_0.22.0-1/userspace/libsinsp/socket_handler.h:1229

    									 sinsp_logger::SEV_INFO);    
g_logger.log("Socket handler (" + m_id + "): "
"SSL socket=" + std::to_string(m_socket) + ", "
"local port=" + std::to_string(get_local_port()),
sinsp_logger::SEV_DEBUG);


actcd19/main/p/performous/performous_1.1+git20181118-2/game/configuration.cc:310

    		else if (type == "int") entryNode->set_attribute("value",std::to_string(item.i()));    
else if (type == "bool") entryNode->set_attribute("value", item.b() ? "true" : "false");
else if (type == "float") entryNode->set_attribute("value",std::to_string(item.f()));
else if (item.get_type() == "string") xmlpp::add_child_element(entryNode, "stringvalue")->add_child_text(item.s());
else if (item.get_type() == "string_list") {


actcd19/main/g/gnss-sdr/gnss-sdr_0.0.10-4/src/core/receiver/gnss_flowgraph.cc:1238

                        try    
{
sat_ = configuration_->property("Channel" + std::to_string(ch_index) + ".satellite", 0);
}
catch (const std::exception& e)


actcd19/main/q/qtwebengine-opensource-src/qtwebengine-opensource-src_5.11.3+dfsg-2/src/3rdparty/chromium/services/ui/ws/window_tree_unittest.cc:1539

      // would be reset to 0 before sending back to clients.    
EXPECT_EQ("OnCaptureChanged new_window=0," +
std::to_string(kEmbedTreeWindowId) +
" old_window=" + kNextWindowClientIdString + "," +
std::to_string(embed_child_window_id.sink_id()),


actcd19/main/g/gazebo/gazebo_9.6.0-1/gazebo/physics/dart/DARTScrewJoint.cc:95

      {    
return this->dataPtr->GetCached<ignition::math::Vector3d>(
"Axis" + std::to_string(_index));
}


actcd19/main/q/qtcreator/qtcreator_4.8.2-1/src/libs/3rdparty/botan/src/lib/asn1/asn1_obj.cpp:48

             else    
{
msg << std::to_string(type_tag);
}


actcd19/main/l/llvm-toolchain-7/llvm-toolchain-7_7.0.1-8/.pc/kfreebsd/kfreebsd-triple-clang.diff/clang/lib/Driver/ToolChains/Clang.cpp:3358

      if (FunctionAlignment) {    
CmdArgs.push_back("-function-alignment");
CmdArgs.push_back(Args.MakeArgString(std::to_string(FunctionAlignment)));
}


actcd19/non-free/i/intel-media-driver-non-free/intel-media-driver-non-free_18.4.0+ds1-1/media_driver/agnostic/common/os/mos_os.c:639

        auto &cmdResInfoPtrs = GetCmdResPtrs(pOsInterface);    

outputFile << "--PerfTag: " << std::to_string(pOsInterface->pfnGetPerfTag(pOsInterface)) << " --Cmd Num: "
<< cmdResInfoPtrs.size() << " --Dump Count: " << ++m_cnt << endl;


actcd19/main/o/osm2pgsql/osm2pgsql_0.96.0+ds-2/middle-pgsql.cpp:267

        };    

copy_buffer = std::to_string(node.id());
copy_buffer += delim;


actcd19/main/l/lizardfs/lizardfs_3.12.0+dfsg-3/src/master/chunk_goal_counters.cc:63

    	if (it == counters_.end() || it->goal != goal) {    
throw ChunkGoalCounters::InvalidOperation(
"Trying to remove non-existent goal: " + std::to_string(goal));
}
it->count--;


actcd19/main/c/cbmc/cbmc_5.10-5/src/solvers/smt2/smt2_conv.cpp:802

      else if(type.id()==ID_unsignedbv)    
{
return "u"+std::to_string(to_unsignedbv_type(type).get_width());
}
else if(type.id()==ID_c_bool)


actcd19/main/p/pcsx2/pcsx2_1.5.0~gfc1d9aef0+dfsg-1/plugins/cdvdGigaherz/src/CDVD.cpp:51

        
#ifndef PCSX2_DEBUG
static std::string s_libname("cdvdGigaherz " + std::to_string(SVN_REV));
#else
static std::string s_libname("cdvdGigaherz Debug " + std::to_string(SVN_REV));


actcd19/main/g/gnss-sdr/gnss-sdr_0.0.9-5/src/tests/system-tests/obs_gps_l1_system_test.cc:229

        config->set_property("SignalSource.sampling_frequency", std::to_string(sampling_rate_internal));    
config->set_property("SignalSource.item_type", "ibyte");
config->set_property("SignalSource.samples", std::to_string(zero));

// Set the Signal Conditioner


actcd19/main/c/cbmc/cbmc_5.6-1/src/cegis/jsa/genetic/jsa_source_provider.cpp:55

      result+=std::to_string(__CPROVER_JSA_MAX_QUERY_SIZE);    
result+="\n#define __CPROVER_JSA_MAX_PRED_SIZE ";
result+=std::to_string(__CPROVER_JSA_MAX_PRED_SIZE);
result+="\n#define __CPROVER_JSA_NUM_PRED_OPS ";
result+=std::to_string(__CPROVER_JSA_NUM_PRED_OPS);


actcd19/main/p/pcsx2/pcsx2_1.5.0~gfc1d9aef0+dfsg-1/common/src/Utilities/Perf.cpp:141

        ml.method_name = m_prefix;    
#else
std::string name = std::string(m_prefix) + "_" + std::to_string(pc);
ml.method_id = iJIT_GetNewMethodID();
ml.method_name = (char *)name.c_str();


actcd19/main/u/ultracopier/ultracopier_1.6.1.3-1/plugins/CopyEngine/Ultracopier/TransferThread.cpp:1808

        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"["+std::to_string(id)+"] start with stat: "+std::to_string(transfer_stat));    
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"["+std::to_string(id)+"] readIsOpeningVariable: "+std::to_string(readIsOpeningVariable)+", readIsOpenVariable: "+std::to_string(readIsOpenVariable)+", readIsReadyVariable: "+std::to_string(readIsReadyVariable)+", readIsFinishVariable: "+std::to_string(readIsFinishVariable)+", readIsClosedVariable: "+std::to_string(readIsClosedVariable));
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"["+std::to_string(id)+"] writeIsOpeningVariable: "+std::to_string(writeIsOpeningVariable)+", writeIsOpenVariable: "+std::to_string(writeIsOpenVariable)+", writeIsReadyVariable: "+std::to_string(writeIsReadyVariable)+", writeIsFinishVariable: "+std::to_string(writeIsFinishVariable)+", writeIsClosedVariable: "+std::to_string(writeIsClosedVariable));
switch(transfer_stat)
{


actcd19/main/m/modsecurity/modsecurity_3.0.3-1/src/operators/verify_ssn.cc:80

        
str_area.append(std::to_string(num[0]) + std::to_string(num[1]) +
std::to_string(num[2]));

str_grp.append(std::to_string(num[3]) + std::to_string(num[4]));


actcd19/main/m/monero/monero_0.13.0.4-2/src/device/device_ledger.cpp:1234

            this->controle_device->mlsag_prehash(blob_x, inputs_size_x, outputs_size_x, hashes_x, outPk_x, prehash_x);    
if (inputs_size) {
log_message("mlsag_prehash", (std::string("inputs_size not null: ") + std::to_string(inputs_size)).c_str());
}
this->key_map.log();


actcd19/main/g/gnss-sdr/gnss-sdr_0.0.10-4/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.cc:225

            {    
bool cboc = configuration_->property(
"Acquisition" + std::to_string(channel_) + ".cboc", false);

char signal[3];


actcd19/main/m/madness/madness_0.10.1~gite4aa500e-3/src/apps/chem/CC2.cc:131

        bool doubles_converged = true;    
for(size_t iter=0; iter < parameters.iter_max_6D; iter++){
output_subsection("Mactoiteration " + std::to_string(iter) + " with excitation energy " + std::to_string(omega));
CC_Timer timer_iter_all(world,"Macroiteration " + stringify(iter));


actcd19/main/s/simgrid/simgrid_3.21+dfsg-4/src/instr/instr_private.hpp:162

        return stream.str();    
}
std::string display_size() override { return std::to_string(send_size); }
};


actcd19/main/h/horizon-eda/horizon-eda_0.20181108-1/src/gen-pkg/gen-pkg.cpp:163

            auto &pad = pkg.pads.emplace(std::piecewise_construct, std::forward_as_tuple(uu), std::forward_as_tuple(uu, ps))    
.first->second;
pad.name = std::to_string(i + 1);
pad.placement.shift.y = y0 - i * pitch;
pad.parameter_set[ParameterID::HOLE_DIAMETER] = 1_mm;


actcd19/main/s/sysdig/sysdig_0.22.0-1/userspace/libsinsp/socket_handler.h:1522

    		if(pending_reqs)    
{
g_logger.log("Socket handler: number of pending DNS cancellation requests is " + std::to_string(pending_reqs),
(pending_reqs > 10) ? sinsp_logger::SEV_WARNING : sinsp_logger::SEV_TRACE);
}


actcd19/main/libf/libfreesrp/libfreesrp_0.3.0-2/src/freesrp_impl.cpp:85

    		libusb_close(_freesrp_handle);    
_freesrp_handle = nullptr;
throw ConnectionError("libusb could not read FreeSRP serial number: error " + std::to_string(ret));
}
else


actcd19/main/s/supertux/supertux_0.6.0-1/src/gui/item_intfield.cpp:84

        *number = new_number;    
} catch (...) {
input = std::to_string(*number);
}
}


actcd19/main/libc/libcereal/libcereal_1.2.2-3/include/cereal/cereal.hpp:679

            auto iter = itsSharedPointerMap.find( id );    
if(iter == itsSharedPointerMap.end())
throw Exception("Error while trying to deserialize a smart pointer. Could not find id " + std::to_string(id));

return iter->second;


actcd19/main/b/botan/botan_2.9.0-2/src/tests/test_pkcs11_low_level.cpp:214

       else    
{
result.test_rc_fail(name, "return value should be: " + std::to_string(static_cast< uint32_t >(expected_return_value)),
static_cast< uint32_t >(rv));
}


actcd19/main/f/freeorion/freeorion_0.4.8-1/Empire/Diplomacy.cpp:29

        std::string retval;    
retval += "Dimplomatic message from : " + std::to_string(m_sender_empire) +
" to: " + std::to_string(m_recipient_empire) + " about: ";
switch (m_type) {
case WAR_DECLARATION: retval += "War Declaration"; break;


actcd19/main/a/android-platform-frameworks-native/android-platform-frameworks-native_8.1.0+r23-2/libs/hwc2on1adapter/HWC2On1Adapter.cpp:1391

    static std::string approximateFloatString(float f) {    
if (static_cast<int32_t>(f) == f) {
return std::to_string(static_cast<int32_t>(f));
}
int32_t truncated = static_cast<int32_t>(f * 10);


actcd19/main/r/rocksdb/rocksdb_5.17.2-3/table/data_block_hash_index_test.cc:182

      ASSERT_EQ(original_size, map_offset);    
for (uint8_t i = 0; i < 100; i++) {
std::string key("key" + std::to_string(i));
uint8_t restart_point = i;
ASSERT_TRUE(


actcd19/main/u/ultracopier/ultracopier_1.6.1.3-1/plugins/CopyEngine/Ultracopier/ScanFileOrFolder.cpp:198

    {    
stopped=false;
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start the listing with destination: "+destination+", mode: "+std::to_string(mode));
destination=resolvDestination(QString::fromStdString(destination)).absoluteFilePath().toStdString();
if(stopIt)


actcd19/main/d/dnsdist/dnsdist_1.3.3-3/test-dnsdistpacketcache_cc.cc:78

        size_t delcounter=0;    
for(delcounter=0; delcounter < counter/1000; ++delcounter) {
DNSName a=DNSName(std::to_string(delcounter))+DNSName(" hello");
vector<uint8_t> query;
DNSPacketWriter pwQ(query, a, QType::A, QClass::IN, 0);


actcd19/contrib/o/openmw/openmw_0.45.0-2/components/esm/mappings.cpp:57

                default:    
throw std::runtime_error("PartReferenceType " +
std::to_string(type) + " not associated with a mesh part");
}
}


actcd19/main/t/thunderbird/thunderbird_60.5.1-1/ipc/glue/GeckoChildProcessHost.cpp:1025

    #endif  // defined(MOZ_SANDBOX)    
mLaunchOptions->handles_to_inherit.push_back(reinterpret_cast<HANDLE>(h));
std::string hStr = std::to_string(h);
cmdLine.AppendLooseValue(UTF8ToWide(hStr));
}


actcd19/main/m/mysql-workbench/mysql-workbench_6.3.10+dfsg-3/.pc/build-i386-json.patch/library/forms/jsonview.cpp:432

              auto newNode = (updateMode) ? node : node->add_child();    
generateTree(objectName.empty() ? jv : obj[objectName], 0, newNode);
newNode->set_string(0, objectName + "{" + std::to_string(obj.size()) + "}");
newNode->set_tag(objectName);
_dataChanged(false);


actcd19/main/m/mysql-workbench/mysql-workbench_6.3.10+dfsg-3/backend/wbprivate/sqlide/wb_live_schema_tree.cpp:1520

                limit_rows = false;    
if (limit_rows)
caption += _(" - Limit ") + std::to_string(limit_rows_count);
}
view_item.caption = caption;


actcd19/main/s/spades/spades_3.13.0+dfsg2-2/src/common/assembly_graph/core/graph_iterators.hpp:173

                            Comparator(), bool canonical_only = false)    
: SmartIterator<Graph, VertexId, Comparator>(
g, "SmartVertexIterator " + std::to_string(get_id()), true,
comparator, canonical_only) {
this->insert(g.begin(), g.end());


actcd19/main/f/flang/flang_20181226-2/flang-driver/unittests/Tooling/ExecutionTest.cpp:271

      for (unsigned i = 1; i <= NumFiles; ++i) {    
std::string File = "f" + std::to_string(i) + ".cc";
std::string Symbol = "looong_function_name_" + std::to_string(i);
Files.push_back(File);
FileToContent[File] = "void " + Symbol + "() {}";


actcd19/main/t/toulbar2/toulbar2_1.0.0+dfsg3-2/src/utils/tb2reader.cpp:1513

                    exit(EXIT_FAILURE);    
}
streamContentVec.push_back(std::make_pair(GCFTemplate[i], std::to_string(cost)));
}
// ---------- Read variable and add it to stream


actcd19/main/c/chromium/chromium_72.0.3626.121-1/v8/src/torque/declarations.cc:278

      for (auto type : specialized_types) {    
std::string type_string = type->MangledName();
result += std::to_string(type_string.size()) + type_string;
}
return result;


actcd19/main/f/ffms2/ffms2_2.23-3/src/core/ffms.cpp:354

    	ReplaceString(s, "%samplerate%", std::to_string(AP->SampleRate));    
ReplaceString(s, "%channels%", std::to_string(AP->Channels));
ReplaceString(s, "%bps%", std::to_string(AP->BitsPerSample));
ReplaceString(s, "%delay%", std::to_string(static_cast<int>(AP->FirstTime)));


actcd19/main/f/freeorion/freeorion_0.4.8-1/UI/TechTreeWnd.cpp:1704

            cost_btn->SetText(cost_str + just_pad + just_pad);    

std::string time_str = std::to_string(this_row_tech->ResearchTime(client_empire_id));
if (GG::Button* time_btn = dynamic_cast<GG::Button*>((size() >= 4) ? at(3) : nullptr))
time_btn->SetText(time_str + just_pad + just_pad);


actcd19/main/b/biboumi/biboumi_8.3-1/src/bridge/bridge.cpp:550

              {    
auto& list = channel_list_cache[iid.get_server()];
const auto res = this->send_matching_channel_list(list, rs_info, iq_id, to_jid, std::to_string(iid));
return res;
}


actcd19/main/u/ultracopier/ultracopier_1.6.1.3-1/plugins/Themes/Oxygen/ThemesFactory.cpp:449

                    currentSpeed=1024*64;    
if(optionsEngine!=NULL)
optionsEngine->setOptionValue("currentSpeed",std::to_string(currentSpeed));
else
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"internal error, crash prevented");


actcd19/main/c/chromium/chromium_72.0.3626.121-1/ui/ozone/platform/wayland/wayland_buffer_manager.cc:253

      if (planes_count != strides.size() || planes_count != offsets.size() ||    
planes_count != modifiers.size()) {
reason = "Number of strides(" + std::to_string(strides.size()) +
")/offsets(" + std::to_string(offsets.size()) + ")/modifiers(" +
std::to_string(modifiers.size()) +


actcd19/main/p/psi4/psi4_1.2.1-2/psi4/src/psi4/libqt/timer.cc:603

                                    str += key_;    
str += " on thread ";
str += std::to_string(thread_rank);
str += " are on and cannot be merged.";
throw PsiException(str, __FILE__, __LINE__);


actcd19/main/libf/libfilezilla/libfilezilla_0.15.1-1/lib/libfilezilla/string.hpp:194

    inline typename std::enable_if<std::is_arithmetic<std::decay_t<Arg>>::value, std::string>::type to_string(Arg && arg)    
{
return std::to_string(std::forward<Arg>(arg));
}


actcd19/main/s/simgrid/simgrid_3.21+dfsg-4/examples/s4u/dht-chord/s4u-dht-chord-node.cpp:134

        
try {
simgrid::s4u::Mailbox::by_name(std::to_string(pred_id_))->put(succ_msg, 10, timeout);
} catch (simgrid::TimeoutError& e) {
XBT_DEBUG("Timeout expired when sending a 'SUCCESSOR_LEAVING' to my predecessor %d", pred_id_);


actcd19/main/g/gnss-sdr/gnss-sdr_0.0.10-4/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc:417

        config->set_property("Acquisition_5X.item_type", "gr_complex");    
config->set_property("Acquisition_5X.coherent_integration_time_ms",
std::to_string(integration_time_ms));
config->set_property("Acquisition_5X.max_dwells", "1");
config->set_property("Acquisition_5X.implementation", "Galileo_E5a_PCPS_Acquisition");


actcd19/main/o/ompl/ompl_1.4.2+ds1-1/demos/HypercubeBenchmark.cpp:110

        ompl::tools::Benchmark::Request request(runtime_limit, memory_limit, run_count);    
ompl::tools::Benchmark b(ss, "HyperCube");
b.addExperimentParameter("num_dims", "INTEGER", std::to_string(ndim));

addPlanner(b, std::make_shared<ompl::geometric::STRIDE>(ss.getSpaceInformation()), range);


actcd19/main/c/chromium/chromium_72.0.3626.121-1/third_party/dawn/src/common/DynamicLib.cpp:87

        
if (proc == nullptr && error != nullptr) {
*error = "Windows Error: " + std::to_string(GetLastError());
}
#elif DAWN_PLATFORM_POSIX


actcd19/main/p/psi4/psi4_1.2.1-2/psi4/src/psi4/libmints/cdsalclist.cc:312

        
name += com.coef > 0.0 ? "+" : "-";
name += std::to_string(std::fabs(com.coef)) + " ";
name += molecule_->label(com.atom);
if (com.xyz == 0)


actcd19/main/u/ultracopier/ultracopier_1.6.1.3-1/plugins/CopyEngine/Ultracopier/TransferThread.cpp:767

    void TransferThread::tryCopyDirectly()    
{
ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"["+std::to_string(id)+"] "+QStringLiteral("need copied directly: %1 to %2").arg(source.absoluteFilePath()).arg(destination.absoluteFilePath()).toStdString());

sended_state_readStopped = false;


actcd19/main/w/widelands/widelands_19+repack-6/src/wui/plot_area.cc:438

     */    
void WuiPlotArea::draw(RenderTarget& dst) {
draw_plot(dst, get_inner_h() - kSpaceBottom, std::to_string(highest_scale_), highest_scale_);
}


actcd19/main/p/psi4/psi4_1.2.1-2/psi4/src/psi4/detci/params.cc:604

          if (i < 1 || i > Parameters_->num_roots) {    
std::string str = "Invalid number of states to average (";
str += std::to_string(i);
str += ")";
throw PsiException(str, __FILE__, __LINE__);


actcd19/main/p/pdns-recursor/pdns-recursor_4.1.11-1/filterpo.cc:347

      if (addr.isIPv4()) {    
const uint8_t* bytes = reinterpret_cast<const uint8_t*>(&addr.sin4.sin_addr.s_addr);
res += DNSName(std::to_string(bytes[3]) + "." + std::to_string(bytes[2]) + "." + std::to_string(bytes[1]) + "." + std::to_string(bytes[0]));
}
else {


actcd19/main/t/trilinos/trilinos_12.12.1-7/packages/stk/stk_simd/unit_tests/SimdFixture.hpp:268

        
virtual std::string get_input_vals(int i) const override {
return std::to_string(x.scalar(i))+" "+std::to_string(y.scalar(i));
}
};


actcd19/main/p/performous/performous_1.1+git20181118-2/game/3dobject.cc:83

    				m_faces.push_back(f);    
} else {
throw std::runtime_error("Invalid face in "+filepath.string()+":"+std::to_string(linenumber));
}
}


actcd19/main/f/freeorion/freeorion_0.4.8-1/util/SitRepEntry.cpp:227

                    UserStringNop("SITREP_SHIP_DAMAGED_AT_SYSTEM_LABEL"), true);    
sitrep.AddVariable(VarText::SHIP_ID_TAG, std::to_string(object_id));
sitrep.AddVariable(VarText::DESIGN_ID_TAG, std::to_string(ship->DesignID()));

} else if (auto planet = std::dynamic_pointer_cast<const Planet>(obj)) {


actcd19/main/o/opensurgsim/opensurgsim_0.7.0-8/SurgSim/Devices/LabJack/UnitTests/LabJackDeviceTest.cpp:158

        
EXPECT_TRUE(consumer->m_lastReceivedInput.scalars().hasEntry(SurgSim::DataStructures::Names::TIMER_INPUT_PREFIX +
std::to_string(0))); // The LabJackDevice provides entries for timer input lines 0 - 6.
}


actcd19/main/f/fw4spl/fw4spl_17.2.0-2/SrcLib/patch/fwMDSemanticPatch/src/fwMDSemanticPatch/V09ALA/V10/fwData/Image.cpp:109

                if (label.empty())    
{
label = "label_" + std::to_string(count++);
}

References

Informative References

[CODESEARCH]
Andrew Tomazos. Code search engine website. URL: https://codesearch.isocpp.org
[DRAGON]
Guy L. Steele Jr.; Jon L White. How to Print Floating-Point Numbers Accurately. URL: https://fmt.dev/papers/p372-steele.pdf
[N1803]
Pete Becker. Simple Numeric Access. URL: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1803.html
[N2408]
Pete Becker. Simple Numeric Access Revision 2. URL: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2408.html
[N4910]
Thomas Köppe. Working Draft, Standard for Programming Language C++. URL: https://wg21.link/n4910
[STD_DISCUSSION]
Deprecate to_string() for floating point types?. URL: https://groups.google.com/a/isocpp.org/g/std-discussion/c/6xhWgsEuvPo