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
4912cff6
Commit
4912cff6
authored
Jun 16, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of mapped types in compile checks (#1200)
parent
46398438
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
6 deletions
+17
-6
include/fmt/format.h
include/fmt/format.h
+8
-4
test/format-test.cc
test/format-test.cc
+9
-2
No files found.
include/fmt/format.h
View file @
4912cff6
...
...
@@ -2096,10 +2096,14 @@ FMT_CONSTEXPR void parse_format_string(basic_string_view<Char> format_str,
template
<
typename
T
,
typename
ParseContext
>
FMT_CONSTEXPR
const
typename
ParseContext
::
char_type
*
parse_format_specs
(
ParseContext
&
ctx
)
{
// GCC 7.2 requires initializer.
typedef
typename
ParseContext
::
char_type
char_type
;
conditional_t
<
has_formatter
<
T
,
buffer_context
<
char_type
>>::
value
,
formatter
<
T
,
char_type
>
,
using
char_type
=
typename
ParseContext
::
char_type
;
using
context
=
buffer_context
<
char_type
>
;
using
mapped_type
=
conditional_t
<
internal
::
mapped_type_constant
<
T
,
context
>::
value
!=
internal
::
custom_type
,
decltype
(
arg_mapper
<
context
>
().
map
(
std
::
declval
<
T
>
())),
T
>
;
conditional_t
<
has_formatter
<
mapped_type
,
context
>::
value
,
formatter
<
mapped_type
,
char_type
>
,
internal
::
fallback_formatter
<
T
,
char_type
>>
f
;
return
f
.
parse
(
ctx
);
...
...
test/format-test.cc
View file @
4912cff6
...
...
@@ -1836,6 +1836,15 @@ TEST(FormatTest, UnpackedArgs) {
6
,
7
,
8
,
9
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
));
}
struct
string_like
{};
fmt
::
string_view
to_string_view
(
string_like
)
{
return
"foo"
;
}
TEST
(
FormatTest
,
CompileTimeString
)
{
EXPECT_EQ
(
"42"
,
fmt
::
format
(
FMT_STRING
(
"{}"
),
42
));
EXPECT_EQ
(
L"42"
,
fmt
::
format
(
FMT_STRING
(
L"{}"
),
42
));
EXPECT_EQ
(
"foo"
,
fmt
::
format
(
FMT_STRING
(
"{}"
),
string_like
()));
}
#if FMT_USE_USER_DEFINED_LITERALS
// Passing user-defined literals directly to EXPECT_EQ causes problems
// with macro argument stringification (#) on some versions of GCC.
...
...
@@ -1867,8 +1876,6 @@ TEST(LiteralsTest, NamedArg) {
TEST
(
FormatTest
,
UdlTemplate
)
{
EXPECT_EQ
(
"foo"
,
"foo"
_format
());
EXPECT_EQ
(
" 42"
,
"{0:10}"
_format
(
42
));
EXPECT_EQ
(
"42"
,
fmt
::
format
(
FMT_STRING
(
"{}"
),
42
));
EXPECT_EQ
(
L"42"
,
fmt
::
format
(
FMT_STRING
(
L"{}"
),
42
));
}
#endif // FMT_USE_USER_DEFINED_LITERALS
...
...
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