MCPcopy Create free account
hub / github.com/apache/arrow / ToChars

Function ToChars

cpp/src/arrow/util/string.h:125–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123/// and might also be faster.
124template <typename T, typename... Args>
125std::string ToChars(T value, Args&&... args) {
126 if constexpr (!have_to_chars<T>) {
127 // Some C++ standard libraries do not yet implement std::to_chars for all types,
128 // in which case we have to fallback to std::string.
129 return std::to_string(value);
130 } else {
131 // According to various sources, the GNU libstdc++ and Microsoft's C++ STL
132 // allow up to 15 bytes of small string optimization, while clang's libc++
133 // goes up to 22 bytes. Choose the pessimistic value.
134 std::string out(15, 0);
135 auto res = std::to_chars(&out.front(), &out.back(), value, args...);
136 while (res.ec != std::errc{}) {
137 assert(res.ec == std::errc::value_too_large);
138 out.resize(out.capacity() * 2);
139 res = std::to_chars(&out.front(), &out.back(), value, args...);
140 }
141 const auto length = res.ptr - out.data();
142 assert(length <= static_cast<int64_t>(out.length()));
143 out.resize(length);
144 return out;
145 }
146}
147
148#else // !__has_include(<charconv>)
149

Callers 15

ToStringMethod · 0.85
operator()Method · 0.85
FieldsFromArraysAndNamesFunction · 0.85
ScanBatchTaskMethod · 0.85
GetNextFilenameMethod · 0.85
ifFunction · 0.85
FromProtoFunction · 0.85
ConvertCookieDateMethod · 0.85
column_metadata.ccFile · 0.85
ToGrpcStatusFunction · 0.85
AddNodeMethod · 0.85

Calls 6

to_stringFunction · 0.85
backMethod · 0.80
resizeMethod · 0.80
capacityMethod · 0.45
dataMethod · 0.45
lengthMethod · 0.45

Tested by 13

TESTFunction · 0.68
ASSERT_OK_AND_ASSIGNFunction · 0.68
RunGroupByFunction · 0.68
GroupByTestFunction · 0.68
TEST_PFunction · 0.68
TEST_FFunction · 0.68
TESTFunction · 0.68
TestSegmentsFunction · 0.68
TESTFunction · 0.68
ValidateConsumeMethod · 0.68
TestRandomConsumeFunction · 0.68