sources/range.h

changeset 137
485cb6d6b98c
parent 109
e4966d7e615d
child 157
42bb29924218
--- a/sources/range.h	Fri May 15 22:46:53 2015 +0300
+++ b/sources/range.h	Wed Jul 20 14:48:47 2016 +0300
@@ -67,7 +67,7 @@
 
 		bool operator!= (const Iterator& other) const
 		{
-			return value != other.value;
+			return value < other.value;
 		}
 
 		Iterator& operator++()
@@ -90,18 +90,12 @@
 
 	Iterator begin() const
 	{
-		Iterator it;
-		it.value = min();
-		it.step = m_step;
-		return it;
+		return Iterator(min(), m_step);
 	}
 
 	Iterator end() const
 	{
-		Iterator it;
-		it.value = max() + 1;
-		it.step = m_step;
-		return it;
+		return Iterator(max(), m_step);
 	}
 
 	T min() const
@@ -150,4 +144,16 @@
 	}
 };
 
+template<typename T>
+Range<T> range(T a, T b, T step = 1)
+{
+	return Range<T>(a, b, step);
+}
+
+template<typename T>
+Range<T> range(T b)
+{
+	return Range<T>(T(), b);
+}
+
 END_ZFC_NAMESPACE

mercurial