[Bf-blender-cvs] [dc01c108d4a] functions: improve ArrayRef and StringRef

Jacques Lucke noreply at git.blender.org
Tue Aug 20 18:32:49 CEST 2019


Commit: dc01c108d4a871c020ae9bfbb1cd908b4b5cf7d2
Author: Jacques Lucke
Date:   Tue Aug 20 18:07:31 2019 +0200
Branches: functions
https://developer.blender.org/rBdc01c108d4a871c020ae9bfbb1cd908b4b5cf7d2

improve ArrayRef and StringRef

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

M	source/blender/blenlib/BLI_array_ref.hpp
M	source/blender/blenlib/BLI_string_ref.hpp

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

diff --git a/source/blender/blenlib/BLI_array_ref.hpp b/source/blender/blenlib/BLI_array_ref.hpp
index f6ceb819dd8..eb49c155c97 100644
--- a/source/blender/blenlib/BLI_array_ref.hpp
+++ b/source/blender/blenlib/BLI_array_ref.hpp
@@ -31,9 +31,9 @@
 #include <array>
 #include <algorithm>
 #include <iostream>
+#include <string>
 
 #include "BLI_utildefines.h"
-#include "BLI_string_ref.hpp"
 #include "BLI_memory.hpp"
 
 namespace BLI {
@@ -272,7 +272,7 @@ template<typename T> class ArrayRef {
    * A debug utility to print the content of the array ref. Every element will be printed on a
    * separate line using the given callback.
    */
-  template<typename PrintLineF> void print_as_lines(StringRef name, PrintLineF print_line) const
+  template<typename PrintLineF> void print_as_lines(std::string name, PrintLineF print_line) const
   {
     std::cout << "ArrayRef: " << name << " \tSize:" << m_size << '\n';
     for (const T &value : *this) {
diff --git a/source/blender/blenlib/BLI_string_ref.hpp b/source/blender/blenlib/BLI_string_ref.hpp
index 947cdb52052..41f0c80af30 100644
--- a/source/blender/blenlib/BLI_string_ref.hpp
+++ b/source/blender/blenlib/BLI_string_ref.hpp
@@ -33,6 +33,7 @@
 
 #include "BLI_utildefines.h"
 #include "BLI_alloca.h"
+#include "BLI_array_ref.hpp"
 
 namespace BLI {
 
@@ -73,6 +74,11 @@ class StringRefBase {
     return m_data[index];
   }
 
+  operator ArrayRef<char>() const
+  {
+    return ArrayRef<char>(m_data, m_size);
+  }
+
   const char *begin() const
   {
     return m_data;



More information about the Bf-blender-cvs mailing list