src/functional.h

changeset 106
128efb9d148b
parent 63
f7dd937667a5
child 123
e3fe3617b631
--- a/src/functional.h	Mon Jul 19 23:41:52 2021 +0300
+++ b/src/functional.h	Tue Jul 20 01:22:01 2021 +0300
@@ -157,3 +157,29 @@
 		return result;
 	}
 }
+
+template<typename T, typename Fn>
+bool any(T&& container, Fn&& f)
+{
+	for (auto&& x : container)
+	{
+		if (f(x))
+		{
+			return true;
+		}
+	}
+	return false;
+}
+
+template<typename T, typename Fn>
+bool all(T&& container, Fn&& f)
+{
+	for (auto&& x : container)
+	{
+		if (not f(x))
+		{
+			return false;
+		}
+	}
+	return true;
+}

mercurial