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
f2990109
Commit
f2990109
authored
Sep 23, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't use const char* overload of operator<< (#1309)
parent
758446c8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
include/fmt/ostream.h
include/fmt/ostream.h
+5
-5
test/ostream-test.cc
test/ostream-test.cc
+12
-0
No files found.
include/fmt/ostream.h
View file @
f2990109
...
...
@@ -46,9 +46,9 @@ template <class Char> class formatbuf : public std::basic_streambuf<Char> {
template
<
typename
Char
>
struct
test_stream
:
std
::
basic_ostream
<
Char
>
{
private:
struct
null
;
// Hide all operator<< from std::basic_ostream<Char>.
void
operator
<<
(
null
);
void_t
<>
operator
<<
(
null
<>
);
void_t
<>
operator
<<
(
const
Char
*
);
};
// Checks if T has a user-defined operator<< (e.g. not a member of
...
...
@@ -56,9 +56,9 @@ template <typename Char> struct test_stream : std::basic_ostream<Char> {
template
<
typename
T
,
typename
Char
>
class
is_streamable
{
private:
template
<
typename
U
>
static
decltype
((
void
)
(
std
::
declval
<
test_stream
<
Char
>&>
()
<<
std
::
declval
<
U
>
()),
std
::
true_type
())
static
bool_constant
<!
std
::
is_same
<
decltype
(
std
::
declval
<
test_stream
<
Char
>&>
()
<<
std
::
declval
<
U
>
()),
void_t
<>>::
value
>
test
(
int
);
template
<
typename
>
static
std
::
false_type
test
(...);
...
...
test/ostream-test.cc
View file @
f2990109
...
...
@@ -242,3 +242,15 @@ TEST(FormatTest, UDL) {
EXPECT_EQ
(
"{}"
_format
(
"test"
),
"test"
);
}
#endif
template
<
typename
T
>
struct
convertible
{
T
value
;
explicit
convertible
(
const
T
&
val
)
:
value
(
val
)
{}
operator
T
()
const
{
return
value
;
}
};
TEST
(
OStreamTest
,
ConvertibleToCString
)
{
EXPECT_EQ
(
"x"
,
fmt
::
format
(
"{}"
,
convertible
<
char
>
(
'x'
)));
EXPECT_EQ
(
"foo"
,
fmt
::
format
(
"{}"
,
convertible
<
const
char
*>
(
"foo"
)));
}
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