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
80ce222c
Commit
80ce222c
authored
Mar 28, 2020
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix wide print overload (#1609)
parent
2864e843
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
include/fmt/core.h
include/fmt/core.h
+10
-9
test/format-test.cc
test/format-test.cc
+2
-0
No files found.
include/fmt/core.h
View file @
80ce222c
...
@@ -326,8 +326,8 @@ FMT_CONSTEXPR typename std::make_unsigned<Int>::type to_unsigned(Int value) {
...
@@ -326,8 +326,8 @@ FMT_CONSTEXPR typename std::make_unsigned<Int>::type to_unsigned(Int value) {
constexpr
unsigned
char
micro
[]
=
"\u00B5"
;
constexpr
unsigned
char
micro
[]
=
"\u00B5"
;
constexpr
bool
is_utf8
()
{
template
<
typename
Char
>
constexpr
bool
is_unicode
()
{
return
FMT_UNICODE
||
return
FMT_UNICODE
||
sizeof
(
Char
)
!=
1
||
(
sizeof
(
micro
)
==
3
&&
micro
[
0
]
==
0xC2
&&
micro
[
1
]
==
0xB5
);
(
sizeof
(
micro
)
==
3
&&
micro
[
0
]
==
0xC2
&&
micro
[
1
]
==
0xB5
);
}
}
...
@@ -1659,8 +1659,11 @@ typename buffer_context<Char>::iterator vformat_to(
...
@@ -1659,8 +1659,11 @@ typename buffer_context<Char>::iterator vformat_to(
buffer
<
Char
>&
buf
,
basic_string_view
<
Char
>
format_str
,
buffer
<
Char
>&
buf
,
basic_string_view
<
Char
>
format_str
,
basic_format_args
<
buffer_context
<
type_identity_t
<
Char
>>>
args
);
basic_format_args
<
buffer_context
<
type_identity_t
<
Char
>>>
args
);
FMT_API
void
vprint_mojibake
(
std
::
FILE
*
,
string_view
,
format_args
);
template
<
typename
Char
,
typename
Args
,
FMT_ENABLE_IF
(
!
std
::
is_same
<
Char
,
char
>
::
value
)
>
inline
void
vprint_mojibake
(
std
::
FILE
*
,
basic_string_view
<
Char
>
,
const
Args
&
)
{}
FMT_API
void
vprint_mojibake
(
std
::
FILE
*
,
string_view
,
format_args
);
#ifndef _WIN32
#ifndef _WIN32
inline
void
vprint_mojibake
(
std
::
FILE
*
,
string_view
,
format_args
)
{}
inline
void
vprint_mojibake
(
std
::
FILE
*
,
string_view
,
format_args
)
{}
#endif
#endif
...
@@ -1751,10 +1754,9 @@ FMT_API void vprint(std::FILE*, string_view, format_args);
...
@@ -1751,10 +1754,9 @@ FMT_API void vprint(std::FILE*, string_view, format_args);
fmt::print(stderr, "Don't {}!", "panic");
fmt::print(stderr, "Don't {}!", "panic");
\endrst
\endrst
*/
*/
template
<
typename
S
,
typename
...
Args
,
template
<
typename
S
,
typename
...
Args
,
typename
Char
=
char_t
<
S
>
>
FMT_ENABLE_IF
(
internal
::
is_string
<
S
>
::
value
)
>
inline
void
print
(
std
::
FILE
*
f
,
const
S
&
format_str
,
Args
&&
...
args
)
{
inline
void
print
(
std
::
FILE
*
f
,
const
S
&
format_str
,
Args
&&
...
args
)
{
return
internal
::
is_u
tf8
()
return
internal
::
is_u
nicode
<
Char
>
()
?
vprint
(
f
,
to_string_view
(
format_str
),
?
vprint
(
f
,
to_string_view
(
format_str
),
internal
::
make_args_checked
<
Args
...
>
(
format_str
,
args
...))
internal
::
make_args_checked
<
Args
...
>
(
format_str
,
args
...))
:
internal
::
vprint_mojibake
(
:
internal
::
vprint_mojibake
(
...
@@ -1773,10 +1775,9 @@ inline void print(std::FILE* f, const S& format_str, Args&&... args) {
...
@@ -1773,10 +1775,9 @@ inline void print(std::FILE* f, const S& format_str, Args&&... args) {
fmt::print("Elapsed time: {0:.2f} seconds", 1.23);
fmt::print("Elapsed time: {0:.2f} seconds", 1.23);
\endrst
\endrst
*/
*/
template
<
typename
S
,
typename
...
Args
,
template
<
typename
S
,
typename
...
Args
,
typename
Char
=
char_t
<
S
>
>
FMT_ENABLE_IF
(
internal
::
is_string
<
S
>
::
value
)
>
inline
void
print
(
const
S
&
format_str
,
Args
&&
...
args
)
{
inline
void
print
(
const
S
&
format_str
,
Args
&&
...
args
)
{
return
internal
::
is_u
tf8
()
return
internal
::
is_u
nicode
<
Char
>
()
?
vprint
(
to_string_view
(
format_str
),
?
vprint
(
to_string_view
(
format_str
),
internal
::
make_args_checked
<
Args
...
>
(
format_str
,
args
...))
internal
::
make_args_checked
<
Args
...
>
(
format_str
,
args
...))
:
internal
::
vprint_mojibake
(
:
internal
::
vprint_mojibake
(
...
...
test/format-test.cc
View file @
80ce222c
...
@@ -1757,6 +1757,8 @@ TEST(FormatTest, Print) {
...
@@ -1757,6 +1757,8 @@ TEST(FormatTest, Print) {
EXPECT_WRITE
(
stderr
,
fmt
::
print
(
stderr
,
"Don't {}!"
,
"panic"
),
EXPECT_WRITE
(
stderr
,
fmt
::
print
(
stderr
,
"Don't {}!"
,
"panic"
),
"Don't panic!"
);
"Don't panic!"
);
#endif
#endif
// Check that the wide print overload compiles.
if
(
fmt
::
internal
::
const_check
(
false
))
fmt
::
print
(
L"test"
);
}
}
TEST
(
FormatTest
,
Variadic
)
{
TEST
(
FormatTest
,
Variadic
)
{
...
...
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