[Bf-blender-cvs] [53d00eb08b6] functions: simplify array printing

Jacques Lucke noreply at git.blender.org
Fri Jul 12 14:50:20 CEST 2019


Commit: 53d00eb08b682f6e19a8d3d4557bfa261db492c1
Author: Jacques Lucke
Date:   Fri Jul 12 10:14:27 2019 +0200
Branches: functions
https://developer.blender.org/rB53d00eb08b682f6e19a8d3d4557bfa261db492c1

simplify array printing

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

M	source/blender/blenlib/BLI_array_ref.hpp

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

diff --git a/source/blender/blenlib/BLI_array_ref.hpp b/source/blender/blenlib/BLI_array_ref.hpp
index 1c97ea7b537..71f55feea39 100644
--- a/source/blender/blenlib/BLI_array_ref.hpp
+++ b/source/blender/blenlib/BLI_array_ref.hpp
@@ -30,8 +30,10 @@
 #include <vector>
 #include <array>
 #include <algorithm>
+#include <iostream>
 
 #include "BLI_utildefines.h"
+#include "BLI_string_ref.hpp"
 
 namespace BLI {
 
@@ -251,6 +253,16 @@ template<typename T> class ArrayRef {
     }
     return fallback;
   }
+
+  template<typename PrintLineF> void print_as_lines(StringRef name, PrintLineF print_line) const
+  {
+    std::cout << "ArrayRef: " << name << " \tSize:" << m_size << '\n';
+    for (const T &value : *this) {
+      std::cout << "  ";
+      print_line(value);
+      std::cout << '\n';
+    }
+  }
 };
 
 template<typename T> ArrayRef<T> ref_c_array(T *array, uint size)



More information about the Bf-blender-cvs mailing list