diff options
Diffstat (limited to 'modules/codec')
-rw-r--r-- | modules/codec/c++/data.hpp | 8 | ||||
-rw-r--r-- | modules/codec/c++/simple.hpp | 2 | ||||
-rw-r--r-- | modules/codec/tests/codec.cpp | 36 |
3 files changed, 19 insertions, 27 deletions
diff --git a/modules/codec/c++/data.hpp b/modules/codec/c++/data.hpp index b1b4729..9f65d08 100644 --- a/modules/codec/c++/data.hpp +++ b/modules/codec/c++/data.hpp @@ -700,14 +700,6 @@ class data<schema::Array<T,Dim>, encode::Native> { static_assert(sizeof...(Dims)==Dim, "Argument size must be equal to the Dimension"); } - constexpr data<T, encode::Native>& at(const std::array<uint64_t, Dim>& ind){ - return value_.at(this->get_flat_index(ind)); - } - - constexpr const data<T, encode::Native>& at(const std::array<uint64_t, Dim>& ind) const { - return value_.at(this->get_flat_index(ind)); - } - data<T, encode::Native>& at(data<schema::UInt64, encode::Native> i) { data<schema::FixedArray<schema::UInt64,Dim>, encode::Native> i_arr; i_arr.at(0u) = i; diff --git a/modules/codec/c++/simple.hpp b/modules/codec/c++/simple.hpp index 4990578..de35c3e 100644 --- a/modules/codec/c++/simple.hpp +++ b/modules/codec/c++/simple.hpp @@ -212,7 +212,7 @@ struct kelsimple_decode<schema::Array<T,Dim>, FromEnc> { template<std::size_t Level> static error_or<void> decode_level(buffer& from, data<schema::Array<T,Dim>, FromEnc>& to, std::array<std::size_t, Dim>& index){ if constexpr (Level == Dim){ - return kelsimple_decode<T, FromEnc>::decode(from, to.at(index)); + return kelsimple_decode<T, FromEnc>::decode(from, {to.at(index)}); }else{ const std::size_t dim_size = to.get_dim_size(Level); for(index[Level] = 0; index[Level] < dim_size; ++index[Level]){ diff --git a/modules/codec/tests/codec.cpp b/modules/codec/tests/codec.cpp index a1f37b8..8f50a1c 100644 --- a/modules/codec/tests/codec.cpp +++ b/modules/codec/tests/codec.cpp @@ -108,13 +108,13 @@ SAW_TEST("Two Dimensional Array") { for(size_t i = 0; i < arr.get_dim_size(0); ++i){ for(size_t j = 0; j < arr.get_dim_size(1); ++j){ ++bar; - arr.at({i,j}).set(bar); + arr.at({{i,j}}).set(bar); } } int sum = 0; for(size_t i = 0; i < arr.get_dim_size(0); ++i){ for(size_t j = 0; j < arr.get_dim_size(1); ++j){ - sum += arr.at({i,j}).get(); + sum += arr.at({{i,j}}).get(); } } SAW_EXPECT(sum == expected_sum, std::to_string(sum) + " is not "+ std::to_string(expected_sum) + ". Expected that data stays correct"); @@ -132,7 +132,7 @@ SAW_TEST("Three Dimensional Array") { for(size_t j = 0; j < arr.get_dim_size(1); ++j){ for(size_t k = 0; k < arr.get_dim_size(2); ++k){ ++bar; - arr.at({i,j,k}).set(bar); + arr.at({{i,j,k}}).set(bar); } } } @@ -140,7 +140,7 @@ SAW_TEST("Three Dimensional Array") { for(size_t i = 0; i < arr.get_dim_size(0); ++i){ for(size_t j = 0; j < arr.get_dim_size(1); ++j){ for(size_t k = 0; k < arr.get_dim_size(2); ++k){ - sum += arr.at({i,j,k}).get(); + sum += arr.at({{i,j,k}}).get(); } } } @@ -202,7 +202,7 @@ SAW_TEST("KelSimple Array write and read back"){ for(std::size_t i = 0; i < 2; ++i) { for(std::size_t j = 0; j < 3; ++j){ - native.at({i,j}).set(i+2*j); + native.at({{i,j}}).set(i+2*j); } } @@ -211,7 +211,7 @@ SAW_TEST("KelSimple Array write and read back"){ for(std::size_t i = 0; i < 2; ++i) { for(std::size_t j = 0; j < 3; ++j){ - native.at({i,j}).set(0); + native.at({{i,j}}).set(0); } } @@ -220,7 +220,7 @@ SAW_TEST("KelSimple Array write and read back"){ for(std::size_t i = 0; i < 2; ++i) { for(std::size_t j = 0; j < 3; ++j){ - SAW_EXPECT(native.at({i,j}).get() == static_cast<int32_t>(i+2*j), "Values incorrectly decoded"); + SAW_EXPECT(native.at({{i,j}}).get() == static_cast<int32_t>(i+2*j), "Values incorrectly decoded"); } } } @@ -234,8 +234,8 @@ SAW_TEST("KelSimple Struct write and read back"){ auto& tda = native.template get<"two_dim_array">(); tda = {1,2}; - tda.at({0,0}).set(5); - tda.at({0,1}).set(3); + tda.at({{0,0}}).set(5); + tda.at({{0,1}}).set(3); native.template get<"number">().set(410); codec<schema::TestStruct, encode::KelSimple> codec; @@ -251,8 +251,8 @@ SAW_TEST("KelSimple Struct write and read back"){ auto& dec_tda = native.template get<"two_dim_array">(); - SAW_EXPECT(dec_tda.at({0,0}).get() == 5, "Incorrect Decoding in array 0,0"); - SAW_EXPECT(dec_tda.at({0,1}).get() == 3, "Incorrect Decoding in array 0,1"); + SAW_EXPECT(dec_tda.at({{0,0}}).get() == 5, "Incorrect Decoding in array 0,0"); + SAW_EXPECT(dec_tda.at({{0,1}}).get() == 3, "Incorrect Decoding in array 0,1"); SAW_EXPECT(native.template get<"number">().get() == 410, "Incorrect Decoding in number"); } @@ -302,8 +302,8 @@ SAW_TEST("KelSimple Tuple write and read back"){ auto& tda = native.template get<0>(); tda = {1,2}; - tda.at({0,0}).set(5); - tda.at({0,1}).set(3); + tda.at({{0,0}}).set(5); + tda.at({{0,1}}).set(3); native.template get<1>().set(410); codec<schema::TestTuple, encode::KelSimple> codec; @@ -319,8 +319,8 @@ SAW_TEST("KelSimple Tuple write and read back"){ auto& dec_tda = native.template get<0>(); - SAW_EXPECT(dec_tda.at({0,0}).get() == 5, "Incorrect Decoding in array 0,0"); - SAW_EXPECT(dec_tda.at({0,1}).get() == 3, "Incorrect Decoding in array 0,1"); + SAW_EXPECT(dec_tda.at({{0,0}}).get() == 5, "Incorrect Decoding in array 0,0"); + SAW_EXPECT(dec_tda.at({{0,1}}).get() == 3, "Incorrect Decoding in array 0,1"); SAW_EXPECT(native.template get<1>().get() == 410, "Incorrect Decoding in number"); } @@ -421,7 +421,7 @@ SAW_TEST("Interface basics"){ auto& val = eov.get_value(); SAW_EXPECT(val.get() == 45, "Sum is incorrect"); - } + } { data<schema::TestInt32Pair, encode::Native> native; @@ -432,7 +432,7 @@ SAW_TEST("Interface basics"){ auto& val = eov.get_value(); SAW_EXPECT(val.get() == -35, "Sum is incorrect"); - } + } { data<schema::TestInt32Pair, encode::Native> native; @@ -443,6 +443,6 @@ SAW_TEST("Interface basics"){ auto& val = eov.get_value(); SAW_EXPECT(val.get() == 200, "Sum is incorrect"); + } } } -} |