From a3ae458a06f43e9c3e0e346d178c91f46094f990 Mon Sep 17 00:00:00 2001 From: Claudius 'keldu' Holeksa Date: Tue, 17 Sep 2024 11:41:12 +0200 Subject: wip --- modules/codec/c++/data_raw.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'modules/codec') diff --git a/modules/codec/c++/data_raw.hpp b/modules/codec/c++/data_raw.hpp index 2da49b4..3447f42 100644 --- a/modules/codec/c++/data_raw.hpp +++ b/modules/codec/c++/data_raw.hpp @@ -483,6 +483,25 @@ class data, encode::NativeRaw> { static_assert(sizeof...(Dims)==Dim, "Argument size must be equal to the Dimension"); } + template + constexpr error_or adopt(typename raw_native_array_type_helper::Type* adoptee, Dims... adoptee_size){ + if(value_ != nullptr){ + return make_error("Can't adopt into existing state"); + } + dims_ = {adoptee_size...}; + value_size_ = get_full_size(); + value_ = adoptee; + + return make_void(); + } + + constexpr error_or::Type*> extract(){ + auto old_val = value_; + value_ = nullptr; + value_size_ = 0u; + return old_val; + } + constexpr data, encode::NativeRaw> at(const std::array& ind){ return {value_[this->get_flat_index(ind)]}; } -- cgit v1.2.3