ostream operator << for range template.
This commit is contained in:
		| @@ -2,6 +2,7 @@ | ||||
| #define THIN_RANGE_H | ||||
|  | ||||
| #include <boost/optional.hpp> | ||||
| #include <ostream> | ||||
|  | ||||
| //---------------------------------------------------------------- | ||||
|  | ||||
| @@ -23,6 +24,24 @@ namespace thin_provisioning { | ||||
| 		maybe begin_; | ||||
| 		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; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| //---------------------------------------------------------------- | ||||
|   | ||||
		Reference in New Issue
	
	Block a user