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
486a80e8
Commit
486a80e8
authored
May 30, 2021
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move wchar_t overloads to xchar.h
parent
19d45f4b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
58 deletions
+58
-58
include/fmt/format.h
include/fmt/format.h
+0
-52
include/fmt/xchar.h
include/fmt/xchar.h
+52
-0
test/format-test.cc
test/format-test.cc
+0
-6
test/wchar-test.cc
test/wchar-test.cc
+6
-0
No files found.
include/fmt/format.h
View file @
486a80e8
...
@@ -2816,26 +2816,6 @@ inline auto format_to(basic_memory_buffer<Char, SIZE, Allocator>& buf,
...
@@ -2816,26 +2816,6 @@ inline auto format_to(basic_memory_buffer<Char, SIZE, Allocator>& buf,
return
detail
::
buffer_appender
<
Char
>
(
buf
);
return
detail
::
buffer_appender
<
Char
>
(
buf
);
}
}
template
<
typename
OutputIt
,
typename
S
,
typename
Char
=
char_t
<
S
>,
FMT_ENABLE_IF
(
detail
::
is_output_iterator
<
OutputIt
,
Char
>::
value
&&
!
std
::
is_same
<
Char
,
char
>::
value
)
>
auto
vformat_to
(
OutputIt
out
,
const
S
&
format_str
,
basic_format_args
<
buffer_context
<
type_identity_t
<
Char
>>>
args
)
->
OutputIt
{
auto
&&
buf
=
detail
::
get_buffer
<
Char
>
(
out
);
detail
::
vformat_to
(
buf
,
to_string_view
(
format_str
),
args
);
return
detail
::
get_iterator
(
buf
);
}
template
<
typename
OutputIt
,
typename
S
,
typename
...
Args
,
typename
Char
=
char_t
<
S
>,
FMT_ENABLE_IF
(
detail
::
is_output_iterator
<
OutputIt
,
Char
>::
value
&&
!
std
::
is_same
<
Char
,
char
>::
value
)
>
inline
auto
format_to
(
OutputIt
out
,
const
S
&
fmt
,
Args
&&
...
args
)
->
OutputIt
{
const
auto
&
vargs
=
fmt
::
make_args_checked
<
Args
...
>
(
fmt
,
args
...);
return
vformat_to
(
out
,
to_string_view
(
fmt
),
vargs
);
}
template
<
typename
OutputIt
,
typename
Locale
,
template
<
typename
OutputIt
,
typename
Locale
,
FMT_ENABLE_IF
(
detail
::
is_output_iterator
<
OutputIt
,
char
>
::
value
&&
FMT_ENABLE_IF
(
detail
::
is_output_iterator
<
OutputIt
,
char
>
::
value
&&
detail
::
is_locale
<
Locale
>::
value
)
>
detail
::
is_locale
<
Locale
>::
value
)
>
...
@@ -2854,38 +2834,6 @@ FMT_INLINE auto format_to(OutputIt out, const Locale& loc,
...
@@ -2854,38 +2834,6 @@ FMT_INLINE auto format_to(OutputIt out, const Locale& loc,
format_string
<
T
...
>
fmt
,
T
&&
...
args
)
->
OutputIt
{
format_string
<
T
...
>
fmt
,
T
&&
...
args
)
->
OutputIt
{
return
vformat_to
(
loc
,
out
,
fmt
,
fmt
::
make_format_args
(
args
...));
return
vformat_to
(
loc
,
out
,
fmt
,
fmt
::
make_format_args
(
args
...));
}
}
template
<
typename
OutputIt
,
typename
Char
,
typename
...
Args
,
FMT_ENABLE_IF
(
detail
::
is_output_iterator
<
OutputIt
,
Char
>
::
value
&&
!
std
::
is_same
<
Char
,
char
>::
value
)
>
inline
auto
vformat_to_n
(
OutputIt
out
,
size_t
n
,
basic_string_view
<
Char
>
format_str
,
basic_format_args
<
buffer_context
<
type_identity_t
<
Char
>>>
args
)
->
format_to_n_result
<
OutputIt
>
{
detail
::
iterator_buffer
<
OutputIt
,
Char
,
detail
::
fixed_buffer_traits
>
buf
(
out
,
n
);
detail
::
vformat_to
(
buf
,
format_str
,
args
);
return
{
buf
.
out
(),
buf
.
count
()};
}
template
<
typename
OutputIt
,
typename
S
,
typename
...
Args
,
typename
Char
=
char_t
<
S
>,
FMT_ENABLE_IF
(
detail
::
is_output_iterator
<
OutputIt
,
Char
>::
value
&&
!
std
::
is_same
<
Char
,
char
>::
value
)
>
inline
auto
format_to_n
(
OutputIt
out
,
size_t
n
,
const
S
&
fmt
,
const
Args
&
...
args
)
->
format_to_n_result
<
OutputIt
>
{
const
auto
&
vargs
=
fmt
::
make_args_checked
<
Args
...
>
(
fmt
,
args
...);
return
vformat_to_n
(
out
,
n
,
to_string_view
(
fmt
),
vargs
);
}
template
<
typename
S
,
typename
...
Args
,
typename
Char
=
char_t
<
S
>,
FMT_ENABLE_IF
(
!
std
::
is_same
<
Char
,
char
>::
value
)
>
inline
auto
formatted_size
(
const
S
&
fmt
,
Args
&&
...
args
)
->
size_t
{
detail
::
counting_buffer
<
Char
>
buf
;
const
auto
&
vargs
=
fmt
::
make_args_checked
<
Args
...
>
(
fmt
,
args
...);
detail
::
vformat_to
(
buf
,
to_string_view
(
fmt
),
vargs
);
return
buf
.
count
();
}
FMT_MODULE_EXPORT_END
FMT_MODULE_EXPORT_END
FMT_END_NAMESPACE
FMT_END_NAMESPACE
...
...
include/fmt/xchar.h
View file @
486a80e8
...
@@ -91,6 +91,26 @@ inline std::basic_string<Char> format(const Locale& loc, const S& format_str,
...
@@ -91,6 +91,26 @@ inline std::basic_string<Char> format(const Locale& loc, const S& format_str,
fmt
::
make_args_checked
<
Args
...
>
(
format_str
,
args
...));
fmt
::
make_args_checked
<
Args
...
>
(
format_str
,
args
...));
}
}
template
<
typename
OutputIt
,
typename
S
,
typename
Char
=
char_t
<
S
>,
FMT_ENABLE_IF
(
detail
::
is_output_iterator
<
OutputIt
,
Char
>::
value
&&
detail
::
is_exotic_char
<
Char
>::
value
)
>
auto
vformat_to
(
OutputIt
out
,
const
S
&
format_str
,
basic_format_args
<
buffer_context
<
type_identity_t
<
Char
>>>
args
)
->
OutputIt
{
auto
&&
buf
=
detail
::
get_buffer
<
Char
>
(
out
);
detail
::
vformat_to
(
buf
,
to_string_view
(
format_str
),
args
);
return
detail
::
get_iterator
(
buf
);
}
template
<
typename
OutputIt
,
typename
S
,
typename
...
Args
,
typename
Char
=
char_t
<
S
>,
FMT_ENABLE_IF
(
detail
::
is_output_iterator
<
OutputIt
,
Char
>::
value
&&
detail
::
is_exotic_char
<
Char
>::
value
)
>
inline
auto
format_to
(
OutputIt
out
,
const
S
&
fmt
,
Args
&&
...
args
)
->
OutputIt
{
const
auto
&
vargs
=
fmt
::
make_args_checked
<
Args
...
>
(
fmt
,
args
...);
return
vformat_to
(
out
,
to_string_view
(
fmt
),
vargs
);
}
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
&&
...
@@ -116,6 +136,38 @@ inline auto format_to(OutputIt out, const Locale& loc, const S& format_str,
...
@@ -116,6 +136,38 @@ inline auto format_to(OutputIt out, const Locale& loc, const S& format_str,
return
vformat_to
(
out
,
loc
,
to_string_view
(
format_str
),
vargs
);
return
vformat_to
(
out
,
loc
,
to_string_view
(
format_str
),
vargs
);
}
}
template
<
typename
OutputIt
,
typename
Char
,
typename
...
Args
,
FMT_ENABLE_IF
(
detail
::
is_output_iterator
<
OutputIt
,
Char
>
::
value
&&
detail
::
is_exotic_char
<
Char
>::
value
)
>
inline
auto
vformat_to_n
(
OutputIt
out
,
size_t
n
,
basic_string_view
<
Char
>
format_str
,
basic_format_args
<
buffer_context
<
type_identity_t
<
Char
>>>
args
)
->
format_to_n_result
<
OutputIt
>
{
detail
::
iterator_buffer
<
OutputIt
,
Char
,
detail
::
fixed_buffer_traits
>
buf
(
out
,
n
);
detail
::
vformat_to
(
buf
,
format_str
,
args
);
return
{
buf
.
out
(),
buf
.
count
()};
}
template
<
typename
OutputIt
,
typename
S
,
typename
...
Args
,
typename
Char
=
char_t
<
S
>,
FMT_ENABLE_IF
(
detail
::
is_output_iterator
<
OutputIt
,
Char
>::
value
&&
detail
::
is_exotic_char
<
Char
>::
value
)
>
inline
auto
format_to_n
(
OutputIt
out
,
size_t
n
,
const
S
&
fmt
,
const
Args
&
...
args
)
->
format_to_n_result
<
OutputIt
>
{
const
auto
&
vargs
=
fmt
::
make_args_checked
<
Args
...
>
(
fmt
,
args
...);
return
vformat_to_n
(
out
,
n
,
to_string_view
(
fmt
),
vargs
);
}
template
<
typename
S
,
typename
...
Args
,
typename
Char
=
char_t
<
S
>,
FMT_ENABLE_IF
(
detail
::
is_exotic_char
<
Char
>::
value
)
>
inline
auto
formatted_size
(
const
S
&
fmt
,
Args
&&
...
args
)
->
size_t
{
detail
::
counting_buffer
<
Char
>
buf
;
const
auto
&
vargs
=
fmt
::
make_args_checked
<
Args
...
>
(
fmt
,
args
...);
detail
::
vformat_to
(
buf
,
to_string_view
(
fmt
),
vargs
);
return
buf
.
count
();
}
inline
void
vprint
(
std
::
FILE
*
f
,
wstring_view
fmt
,
wformat_args
args
)
{
inline
void
vprint
(
std
::
FILE
*
f
,
wstring_view
fmt
,
wformat_args
args
)
{
wmemory_buffer
buffer
;
wmemory_buffer
buffer
;
detail
::
vformat_to
(
buffer
,
fmt
,
args
);
detail
::
vformat_to
(
buffer
,
fmt
,
args
);
...
...
test/format-test.cc
View file @
486a80e8
...
@@ -1890,12 +1890,6 @@ TEST(format_test, format_to) {
...
@@ -1890,12 +1890,6 @@ TEST(format_test, format_to) {
EXPECT_EQ
(
"part1part2"
,
s
);
EXPECT_EQ
(
"part1part2"
,
s
);
}
}
TEST
(
format_test
,
format_to_wide
)
{
std
::
vector
<
wchar_t
>
buf
;
fmt
::
format_to
(
std
::
back_inserter
(
buf
),
L"{}{}"
,
42
,
L'\0'
);
EXPECT_STREQ
(
buf
.
data
(),
L"42"
);
}
TEST
(
format_test
,
format_to_memory_buffer
)
{
TEST
(
format_test
,
format_to_memory_buffer
)
{
auto
buf
=
fmt
::
basic_memory_buffer
<
char
,
100
>
();
auto
buf
=
fmt
::
basic_memory_buffer
<
char
,
100
>
();
fmt
::
format_to
(
buf
,
"{}"
,
"foo"
);
fmt
::
format_to
(
buf
,
"{}"
,
"foo"
);
...
...
test/wchar-test.cc
View file @
486a80e8
...
@@ -24,6 +24,12 @@ TEST(wchar_test, format_explicitly_convertible_to_wstring_view) {
...
@@ -24,6 +24,12 @@ TEST(wchar_test, format_explicitly_convertible_to_wstring_view) {
}
}
#endif
#endif
TEST
(
wchar_test
,
format_to
)
{
auto
buf
=
std
::
vector
<
wchar_t
>
();
fmt
::
format_to
(
std
::
back_inserter
(
buf
),
L"{}{}"
,
42
,
L'\0'
);
EXPECT_STREQ
(
buf
.
data
(),
L"42"
);
}
TEST
(
wchar_test
,
vformat_to
)
{
TEST
(
wchar_test
,
vformat_to
)
{
using
wcontext
=
fmt
::
wformat_context
;
using
wcontext
=
fmt
::
wformat_context
;
fmt
::
basic_format_arg
<
wcontext
>
warg
=
fmt
::
detail
::
make_arg
<
wcontext
>
(
42
);
fmt
::
basic_format_arg
<
wcontext
>
warg
=
fmt
::
detail
::
make_arg
<
wcontext
>
(
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