summaryrefslogtreecommitdiff
path: root/modules/codec/c++/data.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/codec/c++/data.hpp')
-rw-r--r--modules/codec/c++/data.hpp30
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;
+ }
+};
}