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
e4ca37cc
Commit
e4ca37cc
authored
Sep 25, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parameterize format_to on string type (#880)
parent
d66fa221
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
include/fmt/format.h
include/fmt/format.h
+7
-4
test/format-test.cc
test/format-test.cc
+6
-0
No files found.
include/fmt/format.h
View file @
e4ca37cc
...
...
@@ -3501,11 +3501,14 @@ inline OutputIt vformat_to(
fmt::format_to(std::back_inserter(out), "{}", 42);
\endrst
*/
template
<
typename
OutputIt
,
typename
...
Args
>
inline
OutputIt
format_to
(
OutputIt
out
,
string_view
format_str
,
template
<
typename
OutputIt
,
typename
String
,
typename
...
Args
>
inline
OutputIt
format_to
(
OutputIt
out
,
const
String
&
format_str
,
const
Args
&
...
args
)
{
return
vformat_to
(
out
,
format_str
,
make_format_args
<
typename
format_context_t
<
OutputIt
>::
type
>
(
args
...));
internal
::
check_format_string
<
Args
...
>
(
format_str
);
typedef
typename
format_context_t
<
OutputIt
,
FMT_CHAR
(
String
)
>::
type
context_t
;
format_arg_store
<
context_t
,
Args
...
>
as
{
args
...};
return
vformat_to
(
out
,
basic_string_view
<
FMT_CHAR
(
String
)
>
(
format_str
),
basic_format_args
<
context_t
>
(
as
));
}
template
<
typename
OutputIt
>
...
...
test/format-test.cc
View file @
e4ca37cc
...
...
@@ -682,6 +682,12 @@ TEST(FormatToTest, Format) {
EXPECT_EQ
(
"part1part2"
,
s
);
}
TEST
(
FormatToTest
,
WideString
)
{
std
::
vector
<
wchar_t
>
buf
;
fmt
::
format_to
(
std
::
back_inserter
(
buf
),
L"{}{}"
,
42
,
L'\0'
);
EXPECT_STREQ
(
buf
.
data
(),
L"42"
);
}
TEST
(
FormatToTest
,
FormatToNonbackInsertIteratorWithSignAndNumericAlignment
)
{
char
buffer
[
16
]
=
{};
fmt
::
format_to
(
buffer
,
"{: =+}"
,
42.0
);
...
...
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