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:
authorHans Goudey <h.goudey@me.com>2021-10-14 19:06:18 +0300
committerHans Goudey <h.goudey@me.com>2021-10-14 19:06:18 +0300
commitb42ce0c54cab8ff5f85ca795cc1f0dab4308449b (patch)
treea924f6615cf2f6ae1471311bc359d57a283e33f9 /source/blender/functions/FN_generic_virtual_array.hh
parent5e8775a8da93292a6d8ef0eed3b89dea40c94399 (diff)
Functions: Generic array data structure
Sometimes it's useful to pass around a set of values with a generic type. The virtual array data structures allow this, but they don't have logical ownership. My initial use case for this is as a return type for the functions that interpolate curve attributes to evaluated points, but a need for this data structure has come up in a few other places as well. It also reduced the need for templates. Differential Revision: https://developer.blender.org/D11103
Diffstat (limited to 'source/blender/functions/FN_generic_virtual_array.hh')
-rw-r--r--source/blender/functions/FN_generic_virtual_array.hh11
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/functions/FN_generic_virtual_array.hh b/source/blender/functions/FN_generic_virtual_array.hh
index 703118ba23e..8aad017e68b 100644
--- a/source/blender/functions/FN_generic_virtual_array.hh
+++ b/source/blender/functions/FN_generic_virtual_array.hh
@@ -27,6 +27,7 @@
#include "BLI_virtual_array.hh"
+#include "FN_generic_array.hh"
#include "FN_generic_span.hh"
namespace blender::fn {
@@ -398,6 +399,16 @@ template<typename T> class GVArray_For_VArray : public GVArray {
}
};
+class GVArray_For_GArray : public GVArray_For_GSpan {
+ protected:
+ GArray<> array_;
+
+ public:
+ GVArray_For_GArray(GArray<> array) : GVArray_For_GSpan(array.as_span()), array_(std::move(array))
+ {
+ }
+};
+
/* Used to convert any generic virtual array into a typed one. */
template<typename T> class VArray_For_GVArray : public VArray<T> {
protected: