Commit 89654cd1 authored by Alex Alabuzhev's avatar Alex Alabuzhev Committed by Jonathan Müller

to_wstring added

parent 37eb419a
...@@ -262,6 +262,8 @@ Utilities ...@@ -262,6 +262,8 @@ Utilities
.. doxygenfunction:: fmt::to_string(const T&) .. doxygenfunction:: fmt::to_string(const T&)
.. doxygenfunction:: fmt::to_wstring(const T&)
.. doxygenclass:: fmt::BasicStringRef .. doxygenclass:: fmt::BasicStringRef
:members: :members:
......
...@@ -125,6 +125,24 @@ std::string to_string(const T &value) { ...@@ -125,6 +125,24 @@ std::string to_string(const T &value) {
w << value; w << value;
return w.str(); return w.str();
} }
/**
\rst
Converts *value* to ``std::wstring`` using the default format for type *T*.
**Example**::
#include "fmt/string.h"
std::wstring answer = fmt::to_wstring(42);
\endrst
*/
template <typename T>
std::wstring to_wstring(const T &value) {
fmt::WMemoryWriter w;
w << value;
return w.str();
}
} }
#endif // FMT_STRING_H_ #endif // FMT_STRING_H_
...@@ -78,3 +78,7 @@ TEST(StringWriterTest, WString) { ...@@ -78,3 +78,7 @@ TEST(StringWriterTest, WString) {
TEST(StringTest, ToString) { TEST(StringTest, ToString) {
EXPECT_EQ("42", fmt::to_string(42)); EXPECT_EQ("42", fmt::to_string(42));
} }
TEST(StringTest, ToWString) {
EXPECT_EQ(L"42", fmt::to_wstring(42));
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment