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
9ff3b6af
Commit
9ff3b6af
authored
Jun 10, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of compile-time strings when including ostream.h (#768)
parent
e3707ef1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
include/fmt/ostream.h
include/fmt/ostream.h
+4
-3
test/ostream-test.cc
test/ostream-test.cc
+4
-0
No files found.
include/fmt/ostream.h
View file @
9ff3b6af
...
@@ -53,8 +53,7 @@ struct test_stream : std::basic_ostream<Char> {
...
@@ -53,8 +53,7 @@ struct test_stream : std::basic_ostream<Char> {
void
operator
<<
(
null
);
void
operator
<<
(
null
);
};
};
// Checks if T has an overloaded operator<< which is a free function (not a
// Checks if T has a user-defined operator<< (e.g. not a member of std::ostream).
// member of std::ostream).
template
<
typename
T
,
typename
Char
>
template
<
typename
T
,
typename
Char
>
class
is_streamable
{
class
is_streamable
{
private:
private:
...
@@ -69,7 +68,9 @@ class is_streamable {
...
@@ -69,7 +68,9 @@ class is_streamable {
typedef
decltype
(
test
<
T
>
(
0
))
result
;
typedef
decltype
(
test
<
T
>
(
0
))
result
;
public:
public:
static
const
bool
value
=
result
::
value
;
// std::string operator<< is not considered user-defined because we handle strings
// specially.
static
const
bool
value
=
result
::
value
&&
!
std
::
is_same
<
T
,
std
::
string
>::
value
;
};
};
// Disable conversion to int if T has an overloaded operator<< which is a free
// Disable conversion to int if T has an overloaded operator<< which is a free
...
...
test/ostream-test.cc
View file @
9ff3b6af
...
@@ -163,3 +163,7 @@ TEST(OStreamTest, Join) {
...
@@ -163,3 +163,7 @@ TEST(OStreamTest, Join) {
int
v
[
3
]
=
{
1
,
2
,
3
};
int
v
[
3
]
=
{
1
,
2
,
3
};
EXPECT_EQ
(
"1, 2, 3"
,
fmt
::
format
(
"{}"
,
fmt
::
join
(
v
,
v
+
3
,
", "
)));
EXPECT_EQ
(
"1, 2, 3"
,
fmt
::
format
(
"{}"
,
fmt
::
join
(
v
,
v
+
3
,
", "
)));
}
}
TEST
(
OStreamTest
,
ConstexprString
)
{
EXPECT_EQ
(
"42"
,
format
(
fmt
(
"{}"
),
std
::
string
(
"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