[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

@ -91,16 +91,6 @@ namespace persistent_data {
bool damaged_;
block_address damage_begin_;
};
inline
std::ostream &operator <<(std::ostream &out, damage_tracker::maybe_range64 const &mr) {
if (mr)
out << "Just " << *mr;
else
out << "Nothing";
return out;
}
}
//----------------------------------------------------------------

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;
}
}
//----------------------------------------------------------------