diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-04-11 12:54:00 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-04-11 12:54:00 +0200 |
commit | 5c65123b44cd8e9761ff8c812b141a496a649019 (patch) | |
tree | 7b956d22e382ed59c260d7c8de9174eeb5579c6a /modules/codec/c++/data.hpp | |
parent | 0457249dcfea285c4a3685d4806bbb9b39037091 (diff) |
Moving towards more forstio data types
Diffstat (limited to 'modules/codec/c++/data.hpp')
-rw-r--r-- | modules/codec/c++/data.hpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/modules/codec/c++/data.hpp b/modules/codec/c++/data.hpp index 9f65d08..ce57967 100644 --- a/modules/codec/c++/data.hpp +++ b/modules/codec/c++/data.hpp @@ -319,14 +319,6 @@ public: value_{value__} {} - constexpr data<T, encode::Native>& at(const std::array<uint64_t, sizeof...(D)>& ind){ - return value_.at(this->get_flat_index(ind)); - } - - constexpr const data<T, encode::Native>& at(const std::array<uint64_t, sizeof...(D)>& ind) const { - return value_.at(this->get_flat_index(ind)); - } - constexpr data<T, encode::Native>& at(data<schema::UInt64, encode::Native> i) { return value_.at(this->get_flat_index({i.get()})); } @@ -861,5 +853,27 @@ public: } }; +/** + * I need some basic support to be able to have some STL guarantees for now. + * I probably should to a trait check on the encoding to have some guarantees regarding the layout instead. + */ +template<typename Schema, typename Encode> +struct convert_to_stl { + static_assert(always_false<Schema,Encode>, "Encode or Schema not supported for stl conversion"); +}; + +template<typename T, uint64_t Dim> +struct convert_to_stl<schema::FixedArray<T,Dim>, encode::Native> { + using Schema = schema::FixedArray<T,Dim>; + static_assert(is_primitive<T>::value, "Only supports primitives"); + + std::array<typename native_data_type<T>::type, Dim> operator()(const data<Schema,encode::Native>& inp){ + std::array<typename native_data_type<T>::type,Dim> conv; + for(uint64_t i = 0u; i < Dim; ++i){ + conv[i] = inp.at({i}).get(); + } + return conv; + } +}; } |