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
11a14db2
Commit
11a14db2
authored
May 30, 2021
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update format_to taking a buffer and remove undocumented vformat_to overload
parent
832ec098
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
26 deletions
+19
-26
include/fmt/format.h
include/fmt/format.h
+7
-18
include/fmt/xchar.h
include/fmt/xchar.h
+10
-0
test/format-impl-test.cc
test/format-impl-test.cc
+1
-1
test/format-test.cc
test/format-test.cc
+1
-1
test/wchar-test.cc
test/wchar-test.cc
+0
-6
No files found.
include/fmt/format.h
View file @
11a14db2
...
@@ -2795,25 +2795,14 @@ template <typename Locale, typename... T,
...
@@ -2795,25 +2795,14 @@ template <typename Locale, typename... T,
FMT_ENABLE_IF
(
detail
::
is_locale
<
Locale
>
::
value
)
>
FMT_ENABLE_IF
(
detail
::
is_locale
<
Locale
>
::
value
)
>
inline
std
::
string
format
(
const
Locale
&
loc
,
format_string
<
T
...
>
fmt
,
inline
std
::
string
format
(
const
Locale
&
loc
,
format_string
<
T
...
>
fmt
,
T
&&
...
args
)
{
T
&&
...
args
)
{
return
vformat
(
loc
,
fmt
,
fmt
::
make_format_args
(
args
...));
return
vformat
(
loc
,
string_view
(
fmt
)
,
fmt
::
make_format_args
(
args
...));
}
}
template
<
typename
S
,
typename
Char
=
char_t
<
S
>,
template
<
typename
...
T
,
size_t
SIZE
,
typename
Allocator
>
FMT_ENABLE_IF
(
detail
::
is_string
<
S
>::
value
)
>
inline
auto
format_to
(
basic_memory_buffer
<
char
,
SIZE
,
Allocator
>&
buf
,
inline
void
vformat_to
(
format_string
<
T
...
>
fmt
,
T
&&
...
args
)
->
appender
{
detail
::
buffer
<
Char
>&
buf
,
const
S
&
format_str
,
detail
::
vformat_to
(
buf
,
string_view
(
fmt
),
fmt
::
make_format_args
(
args
...));
basic_format_args
<
FMT_BUFFER_CONTEXT
(
type_identity_t
<
Char
>
)
>
args
)
{
return
appender
(
buf
);
return
detail
::
vformat_to
(
buf
,
to_string_view
(
format_str
),
args
);
}
template
<
typename
S
,
typename
...
Args
,
typename
Char
,
size_t
SIZE
,
typename
Allocator
,
FMT_ENABLE_IF
(
detail
::
is_string
<
S
>
::
value
)
>
inline
auto
format_to
(
basic_memory_buffer
<
Char
,
SIZE
,
Allocator
>&
buf
,
const
S
&
format_str
,
Args
&&
...
args
)
->
typename
buffer_context
<
Char
>::
iterator
{
const
auto
&
vargs
=
fmt
::
make_args_checked
<
Args
...
>
(
format_str
,
args
...);
detail
::
vformat_to
(
buf
,
to_string_view
(
format_str
),
vargs
);
return
detail
::
buffer_appender
<
Char
>
(
buf
);
}
}
template
<
typename
OutputIt
,
typename
Locale
,
template
<
typename
OutputIt
,
typename
Locale
,
...
@@ -2823,7 +2812,7 @@ auto vformat_to(OutputIt out, const Locale& loc, string_view fmt,
...
@@ -2823,7 +2812,7 @@ auto vformat_to(OutputIt out, const Locale& loc, string_view fmt,
format_args
args
)
->
OutputIt
{
format_args
args
)
->
OutputIt
{
using
detail
::
get_buffer
;
using
detail
::
get_buffer
;
auto
&&
buf
=
get_buffer
<
char
>
(
out
);
auto
&&
buf
=
get_buffer
<
char
>
(
out
);
detail
::
vformat_to
(
buf
,
string_view
(
fmt
)
,
args
,
detail
::
locale_ref
(
loc
));
detail
::
vformat_to
(
buf
,
fmt
,
args
,
detail
::
locale_ref
(
loc
));
return
detail
::
get_iterator
(
buf
);
return
detail
::
get_iterator
(
buf
);
}
}
...
...
include/fmt/xchar.h
View file @
11a14db2
...
@@ -111,6 +111,16 @@ inline auto format_to(OutputIt out, const S& fmt, Args&&... args) -> OutputIt {
...
@@ -111,6 +111,16 @@ inline auto format_to(OutputIt out, const S& fmt, Args&&... args) -> OutputIt {
return
vformat_to
(
out
,
to_string_view
(
fmt
),
vargs
);
return
vformat_to
(
out
,
to_string_view
(
fmt
),
vargs
);
}
}
template
<
typename
S
,
typename
...
Args
,
typename
Char
,
size_t
SIZE
,
typename
Allocator
,
FMT_ENABLE_IF
(
detail
::
is_string
<
S
>
::
value
)
>
FMT_DEPRECATED
auto
format_to
(
basic_memory_buffer
<
Char
,
SIZE
,
Allocator
>&
buf
,
const
S
&
format_str
,
Args
&&
...
args
)
->
typename
buffer_context
<
Char
>::
iterator
{
const
auto
&
vargs
=
fmt
::
make_args_checked
<
Args
...
>
(
format_str
,
args
...);
detail
::
vformat_to
(
buf
,
to_string_view
(
format_str
),
vargs
);
return
detail
::
buffer_appender
<
Char
>
(
buf
);
}
template
<
typename
Locale
,
typename
S
,
typename
OutputIt
,
typename
...
Args
,
template
<
typename
Locale
,
typename
S
,
typename
OutputIt
,
typename
...
Args
,
typename
Char
=
char_t
<
S
>,
typename
Char
=
char_t
<
S
>,
FMT_ENABLE_IF
(
detail
::
is_output_iterator
<
OutputIt
,
Char
>::
value
&&
FMT_ENABLE_IF
(
detail
::
is_output_iterator
<
OutputIt
,
Char
>::
value
&&
...
...
test/format-impl-test.cc
View file @
11a14db2
...
@@ -308,7 +308,7 @@ TEST(format_impl_test, format_error_code) {
...
@@ -308,7 +308,7 @@ TEST(format_impl_test, format_error_code) {
std
::
string
msg
=
"error 42"
,
sep
=
": "
;
std
::
string
msg
=
"error 42"
,
sep
=
": "
;
{
{
fmt
::
memory_buffer
buffer
;
fmt
::
memory_buffer
buffer
;
format_to
(
buffer
,
"garbage"
);
format_to
(
fmt
::
appender
(
buffer
)
,
"garbage"
);
fmt
::
detail
::
format_error_code
(
buffer
,
42
,
"test"
);
fmt
::
detail
::
format_error_code
(
buffer
,
42
,
"test"
);
EXPECT_EQ
(
"test: "
+
msg
,
to_string
(
buffer
));
EXPECT_EQ
(
"test: "
+
msg
,
to_string
(
buffer
));
}
}
...
...
test/format-test.cc
View file @
11a14db2
...
@@ -1664,7 +1664,7 @@ TEST(format_test, join_bytes) {
...
@@ -1664,7 +1664,7 @@ TEST(format_test, join_bytes) {
std
::
string
vformat_message
(
int
id
,
const
char
*
format
,
fmt
::
format_args
args
)
{
std
::
string
vformat_message
(
int
id
,
const
char
*
format
,
fmt
::
format_args
args
)
{
fmt
::
memory_buffer
buffer
;
fmt
::
memory_buffer
buffer
;
format_to
(
buffer
,
"[{}] "
,
id
);
format_to
(
buffer
,
"[{}] "
,
id
);
vformat_to
(
buffer
,
format
,
args
);
vformat_to
(
fmt
::
appender
(
buffer
)
,
format
,
args
);
return
to_string
(
buffer
);
return
to_string
(
buffer
);
}
}
...
...
test/wchar-test.cc
View file @
11a14db2
...
@@ -42,12 +42,6 @@ TEST(wchar_test, vformat_to) {
...
@@ -42,12 +42,6 @@ TEST(wchar_test, vformat_to) {
EXPECT_EQ
(
L"42"
,
w
);
EXPECT_EQ
(
L"42"
,
w
);
}
}
TEST
(
wchar_test
,
format_to_memory_buffer
)
{
auto
buf
=
fmt
::
wmemory_buffer
();
fmt
::
format_to
(
buf
,
L"{}"
,
L"foo"
);
EXPECT_EQ
(
L"foo"
,
to_string
(
buf
));
}
TEST
(
format_test
,
wide_format_to_n
)
{
TEST
(
format_test
,
wide_format_to_n
)
{
wchar_t
buffer
[
4
];
wchar_t
buffer
[
4
];
buffer
[
3
]
=
L'x'
;
buffer
[
3
]
=
L'x'
;
...
...
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