[Bf-blender-cvs] [6922161179b] functions: SmallVector::all_equal

Jacques Lucke noreply at git.blender.org
Mon Feb 18 18:19:17 CET 2019


Commit: 6922161179bfa474ec17e60bd2bff576c787c2da
Author: Jacques Lucke
Date:   Mon Feb 18 17:20:34 2019 +0100
Branches: functions
https://developer.blender.org/rB6922161179bfa474ec17e60bd2bff576c787c2da

SmallVector::all_equal

===================================================================

M	source/blender/blenlib/BLI_shared.hpp
M	source/blender/blenlib/BLI_small_vector.hpp

===================================================================

diff --git a/source/blender/blenlib/BLI_shared.hpp b/source/blender/blenlib/BLI_shared.hpp
index 1d08922a82b..c7c0355d65b 100644
--- a/source/blender/blenlib/BLI_shared.hpp
+++ b/source/blender/blenlib/BLI_shared.hpp
@@ -127,6 +127,11 @@ namespace BLI {
 		{
 			return a.refcounter()->ptr() == b.refcounter()->ptr();
 		}
+
+		friend bool operator!=(const Shared &a, const Shared &b)
+		{
+			return !(a == b);
+		}
 	};
 
 } /* namespace BLI */
\ No newline at end of file
diff --git a/source/blender/blenlib/BLI_small_vector.hpp b/source/blender/blenlib/BLI_small_vector.hpp
index 8af9945d3da..92e4948da56 100644
--- a/source/blender/blenlib/BLI_small_vector.hpp
+++ b/source/blender/blenlib/BLI_small_vector.hpp
@@ -150,6 +150,19 @@ namespace BLI {
 			return -1;
 		}
 
+		static bool all_equal(const SmallVector &a, const SmallVector &b)
+		{
+			if (a.size() != b.size()) {
+				return false;
+			}
+			for (uint i = 0; i < a.size(); i++) {
+				if (a[i] != b[i]) {
+					return false;
+				}
+			}
+			return true;
+		}
+
 		T &operator[](const int index) const
 		{
 			BLI_assert(this->is_index_in_range(index));



More information about the Bf-blender-cvs mailing list