Commit d3ec9a13 authored by Victor Zverovich's avatar Victor Zverovich

Add support for StringRef in BasicFormatter.

parent 00c9fcf1
......@@ -862,6 +862,11 @@ class BasicFormatter {
string.size = value.size();
}
Arg(StringRef value) : type(STRING), formatter(0) {
string.value = value.c_str();
string.size = value.size();
}
template <typename T>
Arg(const T &value) : type(CUSTOM), formatter(0) {
custom.value = &value;
......
......@@ -1091,6 +1091,10 @@ TEST(FormatterTest, FormatString) {
EXPECT_EQ("test", str(Format("{0}") << std::string("test")));
}
TEST(FormatterTest, FormatStringRef) {
EXPECT_EQ("test", str(Format("{0}") << StringRef("test")));
}
TEST(FormatterTest, FormatUsingIOStreams) {
EXPECT_EQ("a string", str(Format("{0}") << TestString("a string")));
std::string s = str(fmt::Format("The date is {0}") << Date(2012, 12, 9));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment