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
18ac9870
Commit
18ac9870
authored
Feb 17, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix formatting of objects convertible to std::string
parent
ce4a65ff
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
6 deletions
+17
-6
include/fmt/core.h
include/fmt/core.h
+7
-6
test/format-test.cc
test/format-test.cc
+10
-0
No files found.
include/fmt/core.h
View file @
18ac9870
...
...
@@ -570,9 +570,8 @@ FMT_MAKE_VALUE(cstring_type, signed char*, const signed char*)
FMT_MAKE_VALUE
(
cstring_type
,
const
signed
char
*
,
const
signed
char
*
)
FMT_MAKE_VALUE
(
cstring_type
,
unsigned
char
*
,
const
unsigned
char
*
)
FMT_MAKE_VALUE
(
cstring_type
,
const
unsigned
char
*
,
const
unsigned
char
*
)
FMT_MAKE_VALUE
(
string_type
,
basic_string_view
<
Char
>
,
basic_string_view
<
Char
>
)
FMT_MAKE_VALUE
(
string_type
,
const
std
::
basic_string
<
Char
>&
,
FMT_MAKE_VALUE
(
string_type
,
basic_string_view
<
Char
>
,
basic_string_view
<
Char
>
)
FMT_MAKE_VALUE
(
string_type
,
const
std
::
basic_string
<
typename
C
::
char_type
>&
,
basic_string_view
<
Char
>
)
FMT_MAKE_VALUE
(
pointer_type
,
void
*
,
const
void
*
)
FMT_MAKE_VALUE
(
pointer_type
,
const
void
*
,
const
void
*
)
...
...
@@ -593,9 +592,11 @@ inline typename std::enable_if<
typed_value
<
C
,
int_type
>>::
type
make_value
(
const
T
&
val
)
{
return
static_cast
<
int
>
(
val
);
}
template
<
typename
C
,
typename
T
>
inline
typename
std
::
enable_if
<!
convert_to_int
<
T
,
typename
C
::
char_type
>::
value
,
typed_value
<
C
,
custom_type
>>::
type
template
<
typename
C
,
typename
T
,
typename
Char
=
typename
C
::
char_type
>
inline
typename
std
::
enable_if
<
!
convert_to_int
<
T
,
Char
>::
value
&&
!
std
::
is_convertible
<
T
,
std
::
basic_string
<
Char
>>::
value
,
typed_value
<
C
,
custom_type
>>::
type
make_value
(
const
T
&
val
)
{
return
val
;
}
template
<
typename
C
,
typename
T
>
...
...
test/format-test.cc
View file @
18ac9870
...
...
@@ -1213,6 +1213,16 @@ TEST(FormatterTest, FormatStringView) {
EXPECT_EQ
(
"test"
,
format
(
"{0}"
,
string_view
(
"test"
)));
}
struct
ConvertibleToString
{
std
::
string
s
;
ConvertibleToString
()
:
s
(
"foo"
)
{}
operator
const
std
::
string
&
()
const
{
return
s
;
}
};
TEST
(
FormatterTest
,
FormatConvertibleToString
)
{
EXPECT_EQ
(
"foo"
,
format
(
"{}"
,
ConvertibleToString
()));
}
namespace
fmt
{
template
<
>
struct
formatter
<
Date
>
{
...
...
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