[test-utils] Make a template for outputting any optional.

This commit is contained in:
Joe Thornber
2013-05-17 10:54:45 +01:00
parent b0d1fa0851
commit 49da293be9
2 changed files with 12 additions and 10 deletions

View File

@@ -109,6 +109,18 @@ namespace test {
std::auto_ptr<with_directory> dir_;
};
//--------------------------------
template <typename T>
std::ostream &operator <<(std::ostream &out, boost::optional<T> const &maybe) {
if (maybe)
out << "Just [" << *maybe << "]";
else
out << "Nothing";
return out;
}
}
//----------------------------------------------------------------