上記のテストフレームワークでタイプを出力したいと思います。 グーグルはそれが可能であると明確に述べています。
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&)
誰かが助けることができますか?