2013-04-29 19:40:01 +05:30
|
|
|
#ifndef THIN_RANGE_H
|
|
|
|
#define THIN_RANGE_H
|
|
|
|
|
|
|
|
#include <boost/optional.hpp>
|
2013-05-01 21:00:59 +05:30
|
|
|
#include <ostream>
|
2013-04-29 19:40:01 +05:30
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
namespace thin_provisioning {
|
|
|
|
template <typename T>
|
|
|
|
class range {
|
|
|
|
public:
|
|
|
|
typedef boost::optional<T> maybe;
|
|
|
|
|
|
|
|
range(maybe begin = maybe(), maybe end = maybe())
|
|
|
|
: begin_(begin),
|
|
|
|
end_(end) {
|
|
|
|
}
|
|
|
|
|
2013-04-29 20:42:34 +05:30
|
|
|
bool operator ==(range<T> const &r) const {
|
|
|
|
return (begin_ == r.begin_ && end_ == r.end_);
|
|
|
|
}
|
|
|
|
|
2013-04-29 19:40:01 +05:30
|
|
|
maybe begin_;
|
|
|
|
maybe end_;
|
|
|
|
};
|
2013-05-01 21:00:59 +05:30
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2013-04-29 19:40:01 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
#endif
|