From 41354f10f5940c72917eb4205ce5adad26f7a369 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 4 Sep 2014 11:26:43 +0100 Subject: [PATCH] provide << operator for optionals --- thin-provisioning/human_readable_format.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/thin-provisioning/human_readable_format.cc b/thin-provisioning/human_readable_format.cc index 0726aa9..3cfc188 100644 --- a/thin-provisioning/human_readable_format.cc +++ b/thin-provisioning/human_readable_format.cc @@ -26,6 +26,14 @@ using namespace thin_provisioning; //---------------------------------------------------------------- namespace { + template + std::ostream &operator << (ostream &out, boost::optional const &maybe) { + if (maybe) + out << *maybe; + + return out; + } + class hr_emitter : public emitter { public: hr_emitter(ostream &out)