@@ -45,23 +45,23 @@ void processAttribute(const std::string& attrname, // input, attribute name
4545 if (valtype == matlab::data::ArrayType::DOUBLE) {
4646 matlab::data::TypedArray<double > attrvalue_mda = attrvalue;
4747 attrs.Attributes .push_back (std::pair<std::string, common::AttributeValue>(attrname,
48- nostd::span<const double >{&(*attrvalue_mda.cbegin ()), &(* attrvalue_mda.cend () )}));
48+ nostd::span<const double >{&(*attrvalue_mda.cbegin ()), attrvalue_mda.getNumberOfElements ( )}));
4949 } else if (valtype == matlab::data::ArrayType::INT32) {
5050 matlab::data::TypedArray<int32_t > attrvalue_mda = attrvalue;
5151 attrs.Attributes .push_back (std::pair<std::string, common::AttributeValue>(attrname,
52- nostd::span<const int32_t >{&(*attrvalue_mda.cbegin ()), &(* attrvalue_mda.cend () )}));
52+ nostd::span<const int32_t >{&(*attrvalue_mda.cbegin ()), attrvalue_mda.getNumberOfElements ( )}));
5353 } else if (valtype == matlab::data::ArrayType::UINT32) {
5454 matlab::data::TypedArray<uint32_t > attrvalue_mda = attrvalue;
5555 attrs.Attributes .push_back (std::pair<std::string, common::AttributeValue>(attrname,
56- nostd::span<const uint32_t >{&(*attrvalue_mda.cbegin ()), &(* attrvalue_mda.cend () )}));
56+ nostd::span<const uint32_t >{&(*attrvalue_mda.cbegin ()), attrvalue_mda.getNumberOfElements ( )}));
5757 } else if (valtype == matlab::data::ArrayType::INT64) {
5858 matlab::data::TypedArray<int64_t > attrvalue_mda = attrvalue;
5959 attrs.Attributes .push_back (std::pair<std::string, common::AttributeValue>(attrname,
60- nostd::span<const int64_t >{&(*attrvalue_mda.cbegin ()), &(* attrvalue_mda.cend () )}));
60+ nostd::span<const int64_t >{&(*attrvalue_mda.cbegin ()), attrvalue_mda.getNumberOfElements ( )}));
6161 } else if (valtype == matlab::data::ArrayType::LOGICAL) {
6262 matlab::data::TypedArray<bool > attrvalue_mda = attrvalue;
6363 attrs.Attributes .push_back (std::pair<std::string, common::AttributeValue>(attrname,
64- nostd::span<const bool >{&(*attrvalue_mda.cbegin ()), &(* attrvalue_mda.cend () )}));
64+ nostd::span<const bool >{&(*attrvalue_mda.cbegin ()), attrvalue_mda.getNumberOfElements ( )}));
6565 } else if (valtype == matlab::data::ArrayType::MATLAB_STRING) { // string
6666 matlab::data::StringArray attrvalue_mda = attrvalue;
6767 std::vector<nostd::string_view> strarray_attr;
@@ -73,7 +73,7 @@ void processAttribute(const std::string& attrname, // input, attribute name
7373 }
7474 attrs.StringViewBuffer .push_back (strarray_attr);
7575 attrs.Attributes .push_back (std::pair<std::string, common::AttributeValue>(attrname,
76- nostd::span<const nostd::string_view>{&(*attrs.StringViewBuffer .back ().cbegin ()), &(*attrs. StringViewBuffer . back (). cend () )}));
76+ nostd::span<const nostd::string_view>{&(*attrs.StringViewBuffer .back ().cbegin ()), attrvalue_mda. getNumberOfElements ( )}));
7777 } else { // ignore all other types
7878 return ;
7979 }
@@ -85,8 +85,7 @@ void processAttribute(const std::string& attrname, // input, attribute name
8585 }
8686 attrs.DimensionsBuffer .push_back (attrvalue_dims_buffer);
8787 attrs.Attributes .push_back (std::pair<std::string, common::AttributeValue>(sizeattr,
88- nostd::span<const double >{&(*attrs.DimensionsBuffer .back ().cbegin ()),
89- &(*attrs.DimensionsBuffer .back ().cend ())}));
88+ nostd::span<const double >{attrs.DimensionsBuffer .back ().data (), attrvalue_dims_buffer.size ()}));
9089 }
9190}
9291} // namespace
0 commit comments