diff options
author | Claudius 'keldu' Holeksa <mail@keldu.de> | 2024-09-17 11:41:12 +0200 |
---|---|---|
committer | Claudius 'keldu' Holeksa <mail@keldu.de> | 2024-09-17 11:41:12 +0200 |
commit | a3ae458a06f43e9c3e0e346d178c91f46094f990 (patch) | |
tree | 8d36b6eb3d6cca94734264d825f19f583a0ffe74 /modules/codec | |
parent | 1d578450dc82843bd4b24f3a6aad2c1a82bbda5e (diff) |
wip
Diffstat (limited to 'modules/codec')
-rw-r--r-- | modules/codec/c++/data_raw.hpp | 19 |
1 files changed, 19 insertions, 0 deletions
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<schema::Array<T,Dim>, encode::NativeRaw> { static_assert(sizeof...(Dims)==Dim, "Argument size must be equal to the Dimension"); } + template<std::integral... Dims> + constexpr error_or<void> adopt(typename raw_native_array_type_helper<T>::Type* adoptee, Dims... adoptee_size){ + if(value_ != nullptr){ + return make_error<err::invalid_state>("Can't adopt into existing state"); + } + dims_ = {adoptee_size...}; + value_size_ = get_full_size(); + value_ = adoptee; + + return make_void(); + } + + constexpr error_or<typename raw_native_array_type_helper<T>::Type*> extract(){ + auto old_val = value_; + value_ = nullptr; + value_size_ = 0u; + return old_val; + } + constexpr data<schema::Ref<T>, encode::NativeRaw> at(const std::array<uint64_t, Dim>& ind){ return {value_[this->get_flat_index(ind)]}; } |