mirror of
https://github.com/fmtlib/fmt.git
synced 2025-01-09 06:00:07 +00:00
Simplify to_string
This commit is contained in:
parent
b23c8633fa
commit
bb6842ba35
@ -3335,21 +3335,15 @@ auto join(const Range& range, wstring_view sep)
|
|||||||
std::string answer = fmt::to_string(42);
|
std::string answer = fmt::to_string(42);
|
||||||
\endrst
|
\endrst
|
||||||
*/
|
*/
|
||||||
template <typename T> std::string to_string(const T& value) {
|
template <typename T> inline std::string to_string(const T& value) {
|
||||||
std::string str;
|
return format("{}", value);
|
||||||
internal::container_buffer<std::string> buf(str);
|
|
||||||
writer(buf).write(value);
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Converts *value* to ``std::wstring`` using the default format for type *T*.
|
Converts *value* to ``std::wstring`` using the default format for type *T*.
|
||||||
*/
|
*/
|
||||||
template <typename T> std::wstring to_wstring(const T& value) {
|
template <typename T> inline std::wstring to_wstring(const T& value) {
|
||||||
std::wstring str;
|
return format(L"{}", value);
|
||||||
internal::container_buffer<std::wstring> buf(str);
|
|
||||||
wwriter(buf).write(value);
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char, std::size_t SIZE>
|
template <typename Char, std::size_t SIZE>
|
||||||
|
Loading…
Reference in New Issue
Block a user