forked from fmtlib/fmt
Fix handling of types convertible to int
This commit is contained in:
@@ -52,8 +52,10 @@ Yes &convert(std::ostream &);
|
|||||||
|
|
||||||
struct DummyStream : std::ostream {
|
struct DummyStream : std::ostream {
|
||||||
DummyStream(); // Suppress a bogus warning in MSVC.
|
DummyStream(); // Suppress a bogus warning in MSVC.
|
||||||
|
|
||||||
// Hide all operator<< overloads from std::ostream.
|
// Hide all operator<< overloads from std::ostream.
|
||||||
void operator<<(Null<>);
|
template <typename T>
|
||||||
|
typename EnableIf<sizeof(T) == 0>::type operator<<(const T &);
|
||||||
};
|
};
|
||||||
|
|
||||||
No &operator<<(std::ostream &, int);
|
No &operator<<(std::ostream &, int);
|
||||||
|
@@ -172,3 +172,18 @@ TEST(OStreamTest, WriteToOStreamMaxSize) {
|
|||||||
} while (size != 0);
|
} while (size != 0);
|
||||||
fmt::internal::write(os, w);
|
fmt::internal::write(os, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ConvertibleToInt {
|
||||||
|
template <typename ValueType>
|
||||||
|
operator ValueType() const {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
friend std::ostream &operator<<(std::ostream &o, ConvertibleToInt) {
|
||||||
|
return o << "foo";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST(FormatTest, FormatConvertibleToInt) {
|
||||||
|
EXPECT_EQ("foo", fmt::format("{}", ConvertibleToInt()));
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user