我想在提到的测试框架中输出我的类型。 谷歌明确表示这是可能的。
As mentioned earlier, the printer is extensible. That means you can teach it to do a better job at printing your particular type than to dump the bytes. To do that, define << for your type:
namespace foo {
class Bar { ... };
// It's important that PrintTo() is defined in the SAME
// namespace that defines Bar. C++'s look-up rules rely on that.
void PrintTo(const Bar& bar, ::std::ostream* os) {
*os << bar.DebugString(); // whatever needed to print bar to os
}
} // namespace foo
我似乎已经这样做了。但是在尝试编译时,我得到以下信息:
error: no match for ‘operator<<’ in ‘* os << val’ /usr/include/c++/4.4/ostream:108: note: candidates are:
紧随其后的是一长串提案,operator<<
最后我的超载:
std::ostream& Navmii::ProgrammingTest::operator<<(std::ostream&, Navmii::ProgrammingTest::AsciiString&)
有人可以帮忙吗?