ostream operator << for range template.
This commit is contained in:
parent
e1c5d485eb
commit
21603c5a5d
@ -2,6 +2,7 @@
|
|||||||
#define THIN_RANGE_H
|
#define THIN_RANGE_H
|
||||||
|
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
@ -23,6 +24,24 @@ namespace thin_provisioning {
|
|||||||
maybe begin_;
|
maybe begin_;
|
||||||
maybe end_;
|
maybe end_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::ostream &
|
||||||
|
operator <<(std::ostream &out, range<T> const &r) {
|
||||||
|
if (r.begin_)
|
||||||
|
out << "[" << *r.begin_;
|
||||||
|
else
|
||||||
|
out << "[-";
|
||||||
|
|
||||||
|
out << ", ";
|
||||||
|
|
||||||
|
if (r.end_)
|
||||||
|
out << *r.end_ << "]";
|
||||||
|
else
|
||||||
|
out << "-]";
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user