Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-06-10 19:26:11 +0300
committerJacques Lucke <jacques@blender.org>2020-06-10 19:27:18 +0300
commit4c172f7ca6cff1387220696166a6e0ee9758ac98 (patch)
tree161331e2fc05c9537cb1de78972f0f37f081a5dd /source/blender/blenlib/BLI_string_ref.hh
parent2d695367a7880faac46b583686dfaa4d65f7ec14 (diff)
BLI: support constructing StringRef from start and end pointer
Diffstat (limited to 'source/blender/blenlib/BLI_string_ref.hh')
-rw-r--r--source/blender/blenlib/BLI_string_ref.hh10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_string_ref.hh b/source/blender/blenlib/BLI_string_ref.hh
index 8ed923068a8..073137fe175 100644
--- a/source/blender/blenlib/BLI_string_ref.hh
+++ b/source/blender/blenlib/BLI_string_ref.hh
@@ -230,6 +230,16 @@ class StringRef : public StringRefBase {
}
/**
+ * Create a StringRef from a start and end pointer. This invokes undefined behavior when the
+ * second point points to a smaller address than the first one.
+ */
+ StringRef(const char *begin, const char *one_after_end)
+ : StringRefBase(begin, (uint)(one_after_end - begin))
+ {
+ BLI_assert(begin <= one_after_end);
+ }
+
+ /**
* Reference a std::string. Remember that when the std::string is destructed, the StringRef
* will point to uninitialized memory.
*/