Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
2f13d41e
Commit
2f13d41e
authored
Feb 07, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add to_wstring
parent
1e19ae83
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
include/fmt/format.h
include/fmt/format.h
+18
-4
test/format-test.cc
test/format-test.cc
+4
-0
No files found.
include/fmt/format.h
View file @
2f13d41e
...
...
@@ -1327,10 +1327,16 @@ class arg_formatter_base {
FMT_DISALLOW_COPY_AND_ASSIGN
(
arg_formatter_base
);
void
write_char
(
char_type
value
)
{
writer_
.
write_padded
(
1
,
specs_
,
[
value
](
auto
&&
it
)
{
struct
char_writer
{
char_type
value
;
template
<
typename
It
>
void
operator
()(
It
&&
it
)
const
{
*
it
++
=
internal
::
char_traits
<
char_type
>::
cast
(
value
);
});
}
};
void
write_char
(
char_type
value
)
{
writer_
.
write_padded
(
1
,
specs_
,
char_writer
{
value
});
}
void
write_pointer
(
const
void
*
p
)
{
...
...
@@ -2172,11 +2178,11 @@ template <typename Range>
class
basic_writer
{
public:
using
char_type
=
typename
Range
::
value_type
;
using
iterator
=
decltype
(
std
::
declval
<
Range
>
().
begin
());
using
format_specs
=
basic_format_specs
<
char_type
>
;
private:
// Output iterator.
using
iterator
=
decltype
(
std
::
declval
<
Range
>
().
begin
());
iterator
out_
;
std
::
unique_ptr
<
locale_provider
>
locale_
;
...
...
@@ -3145,6 +3151,14 @@ std::string to_string(const T &value) {
return
str
;
}
template
<
typename
T
>
std
::
wstring
to_wstring
(
const
T
&
value
)
{
std
::
wstring
str
;
internal
::
container_buffer
<
std
::
wstring
>
buf
(
str
);
wwriter
(
buf
).
write
(
value
);
return
str
;
}
template
<
typename
Char
>
std
::
basic_string
<
Char
>
to_string
(
const
basic_memory_buffer
<
Char
>
&
buffer
)
{
return
std
::
basic_string
<
Char
>
(
buffer
.
data
(),
buffer
.
size
());
...
...
test/format-test.cc
View file @
2f13d41e
...
...
@@ -1608,6 +1608,10 @@ TEST(FormatTest, ToString) {
EXPECT_EQ
(
"42"
,
fmt
::
to_string
(
42
));
}
TEST
(
FormatTest
,
ToWString
)
{
EXPECT_EQ
(
L"42"
,
fmt
::
to_wstring
(
42
));
}
TEST
(
FormatTest
,
OutputIterators
)
{
std
::
list
<
char
>
out
;
fmt
::
format_to
(
std
::
back_inserter
(
out
),
"{}"
,
42
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment