From 5c65123b44cd8e9761ff8c812b141a496a649019 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 11 Apr 2025 12:54:00 +0200 Subject: Moving towards more forstio data types --- modules/codec/c++/data.hpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'modules/codec/c++/data.hpp') 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& at(const std::array& ind){ - return value_.at(this->get_flat_index(ind)); - } - - constexpr const data& at(const std::array& ind) const { - return value_.at(this->get_flat_index(ind)); - } - constexpr data& at(data 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 +struct convert_to_stl { + static_assert(always_false, "Encode or Schema not supported for stl conversion"); +}; + +template +struct convert_to_stl, encode::Native> { + using Schema = schema::FixedArray; + static_assert(is_primitive::value, "Only supports primitives"); + + std::array::type, Dim> operator()(const data& inp){ + std::array::type,Dim> conv; + for(uint64_t i = 0u; i < Dim; ++i){ + conv[i] = inp.at({i}).get(); + } + return conv; + } +}; } -- cgit v1.2.3